Get the dir listing of an executable without knowing its location

ls -l `whereis gcc`
whereis (1) - locate the binary, source, and manual page files for a command Not actually better, just expanded a bit. The "whereis" command has the following output: whereis gcc gcc: /usr/bin/gcc /usr/lib/gcc /usr/bin/X11/gcc /usr/share/man/man1/gcc.1.gz therefore the 'ls' error on first line, which could be eliminated with a little extra work.
Sample Output
ls: cannot access gcc:: No such file or directory
lrwxrwxrwx 1 root root    7 2011-03-03 00:31 /usr/bin/gcc -> gcc-4.5
lrwxrwxrwx 1 root root    7 2011-03-03 00:31 /usr/bin/X11/gcc -> gcc-4.5
lrwxrwxrwx 1 root root   12 2011-03-03 00:31 /usr/share/man/man1/gcc.1.gz -> gcc-4.5.1.gz

/usr/lib/gcc:
total 4
drwxr-xr-x 3 root root 4096 2011-02-14 18:01 i586-suse-linux

0
By: knathan54
2011-11-15 19:45:08

2 Alternatives + Submit Alt

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: