Why is "which cp | ls -l" not treated as "ls -l $ (which cp)"?

According to the handset methodology on Linux, the output of the first command should be considered as input for the second command. Therefore, when I do which cp | ls -l, it should be considered asls -l $(which cp)

But the conclusion shows something else.

Why is that?

+4
source share
1 answer

lsdoes not accept input from stdin. You can get around this if you need to use xargs:

which cp | xargs ls -l

This will invoke ls -lwith (possibly several if whichmore than one should have been returned) file names as command line arguments without standard input.

+12

All Articles