0

I know this question is asked many times. But it is still unclear to me how we can do this. I can pass the output of one command to another but sometimes it won't work.

I usually enter this command to check where the package is located.

which <package_name>

Example

which chmod

OUTPUT: /usr/bin/chmod

Now, I want to find the size of the file. So, I write this command.

which chmod | du -h

Or detail of file by using this command

which chmod | file

These commands do not work for me. Please someone tell me why this does not work and how can I actually pass output of one command to another command.

THANKS IN ADVANCE.

SOLUTION:

which chmod | xargs -I{} du -sh {}

which chmod | xargs -I{} file {}

xargs will catch the output and pass it to next command

csx4
  • 333
  • 2
  • 6

0 Answers0