I am trying to figure out what is the usage of this command:
echo < a.txtAccording to text book it should redirect a programs standards input. Now I am redirecting a.txt to echo but instead of printing the content of the file it is printing out one empty line! Appreciate if anyone display this behaviour.
85 Answers
echo doesn't read stdin so in this case, the redirect is just meaningless.
echo "Hello" | echo
To print out a file just use the command below
echo "$(<a.txt )"
In Unix, I believe all you have to do, assuming you have a file that isn't hefty is:cat <filename>
No echo required.
use below command to print the file content using echo,
echo `cat file.txt`here you can also get benefit of all echo features, I most like the removing of trailing newline character, (to get exact same hash as that of buffer and not the file)
echo -n `cat file.txt` | sha256sum cat command will display the file with CR or return:
$ cat names.txt
Homer
Marge
Bart
Lisa
Maggieyou could use echo command with cat as command substitution. However, it will replace CR or return (unix: \n) with spaces:
$ echo $(cat names.txt)
Homer Marge Bart Lisa MaggieCould be an interesting feature if you want to pipe to further data processing though. E.g. replacing spaces with sed command.
your can use
type test.txt
pause 1