Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I answered this question but realize that it could be better.

How can I convert:

$ which gjslint
$ cat /usr/local/bin/gjslint

Into something like this:

$ cat < which gjslint
-bash: which: No such file or directory that the output path+filename from which is passed onto cat which then does it's thing (i.e. printing the contents of the filename to the screen).

share|improve this question
Funny, your answer on SO has been updated a minute after I posted mine. – Lekensteyn Jun 10 '11 at 21:02
Not sure what you mean, but my intent was to learn, improve my answer on SO, and thus asked a question on AskUbuntu. – Zabba Jun 10 '11 at 21:23
up vote 7 down vote accepted

Use backticks:

cat `which gjslint`

If the path contains whitespace (unlikely with default paths), you need to put it in parentheses:

cat "`which gjslint`"

An alternative would be cat "$(which gjslint)". The reason I use backticks instead of $() is because it's easier to type, two keystrokes with one hand vs 4 keystrokes with two hands. I am aware of the disadvantages of using ` over $(), but those do no apply in this case. You're not going to nest backticks or use slashes for quickly finding a program.

share|improve this answer
There is an argument that $(which gjslint) is preferable. I can't personally speak for validity of this particular argument, but I do tend to trust the content of the site it was posted on. – ændrük Jun 10 '11 at 21:07
Updated why I use backticks instead of $(). – Lekensteyn Jun 10 '11 at 21:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.