echo with stdin

Why doesnt echo output the contents of the file abc.txt as shown below ?

chid@athena:~$ cat abc.txt
sssss
chid@athena:~$ echo < abc.txt

chid@athena:~$

That is an incorrect usage of "echo".

Do you have something against cat, more, less, page, etc ?

If stdin opens a file and redirects the content of the file to a command
then echo should work

I know this works

dam@athena:~$ more < abc.txt
sssss

Why then doesnt it work with echo ?

If you really want to use echo in that way then try this

xargs echo <filename

Now if you have question regarding xargs then check man page that is really good.

echo doesn't use stdin !

With ksh you can do :

echo "$(<abc.txt)"

Jean-Pierre.

[sri]$ echo "$(<just)"
var=sri
for i in 1 2 3 4 5
do
echo "$var.$i"
done

------------------------------

[sri]$ xargs echo <just
var=sri for i in 1 2 3 4 5 do echo $var.$i done

when i use this command xargs it is giving all line in single line as shown above

so i think it would be better to use first example....

i am woundering that we can use echo in different manner..echo "$(<just)"

Thanks ..jenny...

That is not what echo does. echo prints the commandline arguments it is given, not stdin, not any other file, period. xargs is a workaround that translates things read from stdin into commandline arguments for it, an extra program to join them together. You can limit the number of commands xargs gives to a command like

xargs --max-args=1 echo < file

But, again, why not just use cat? That's what it's there for.