Home > Software engineering >  How can I pipe output into another command?
How can I pipe output into another command?

Time:01-30

I have a script located at /usr/local/bin/gq which is returned by the command whereis gq, well almost. What is actually returned is gq: /usr/local/bin/gq. But the following gives me just the filepath (with some white space)

whereis gq | cut -d ":" -f 2

What I’d like to do is be able to pipe that into cat, so I can see the contents. However the old pipe isn’t working. Any suggestions?

CodePudding user response:

If you want to cat the contents of gq, then how about:

cat $(which gq)

The command which gq will result in /usr/local/bin/gq, and the cat command will act on that.

  •  Tags:  
  • Related