WhiskerBiscuit
WhiskerBiscuit

Reputation: 5157

How can I pipe output into another command?

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?

Upvotes: 0

Views: 527

Answers (1)

Hai Vu
Hai Vu

Reputation: 40773

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.

Upvotes: 1

Related Questions