I am reading some Linux guide and wondering why the following pipe does not work:
cat <filename> | ls -l
While the following command subtitution actually does he job:
ls -l `cat <filename>`
<filename> is a file containing a list of directories.
Thanks for your time.
Pinned topic command substitution vs Pipes
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2007-06-13T20:21:45Z at 2007-06-13T20:21:45Z by SystemAdmin
ishields 2000001P5B988 Posts
Re: command substitution vs Pipes2007-06-13T06:05:35ZThis is the accepted answer. This is the accepted answer.You can only pipe stdout to a [i]filter[/i] which is a command that accepts input from stdin. The [b]ls[/b] command doesn't work as a filter. The man page for a command will tell you whether the command accepts input from stdin.
By the way, your second example will fail if you have blanks in any of your file names, for example a file called "a b c". Try
[b]echo "a b c" > "a b c"
cat "a b c"
ls -l `cat "a b c"`[/b]
SystemAdmin 110000D4XK2364 Posts