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.
This topic has been locked.
2 replies Latest Post - 2007-06-13T20:21:45Z by SystemAdmin
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 PostsACCEPTED ANSWER
Re: command substitution vs Pipes2007-06-13T06:05:35Z in response to SystemAdminYou 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]