Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

When I want to know if a command is a link or not, I do like following.

$ which locate
$ ls -l /usr/bin/locate
lrwxrwxrwx 1 root root 24  5月  3  2012 /usr/bin/locate -> /etc/alternatives/locate

Is is possible to write by using pipe one line? I tried which locate | ls -l. But it doesn't work.

share|improve this question
up vote 2 down vote accepted

You can use xargs to forward the results of one command to another...

which locate | xargs ls -al

share|improve this answer
Thanks! I thought xargs is used only when argument is too long. – ironsand Jul 14 '13 at 2:53
Sure! It's got many handy uses. You're only forwarding one argument to it at a time here, but you can control how multiple arguments are passed to the target command. By default multiple arguments would be interpreted as "ls -al arg1 arg2 arg3" but adding the flag -n1 limits it to one argument resulting in "ls -al arg1; ls -al arg2;..." Use the -t flag to experiment and see the output of the commands xargs generates. – Bill Heller Jul 14 '13 at 3:11
Thanks for your information! – ironsand Jul 15 '13 at 4:21

You can also do

ls -l `which locate`

Also, (at least on linux), take a look at:

namei `which locate`
share|improve this answer
I didn't know namei command. Thanks! – ironsand Jul 14 '13 at 2:53

readlink will print the link target, or nothing (and return false) if its subject isn't a link.

which locate | xargs readlink
share|improve this answer
I always used ls -l to find link source. Thanks for your info! – ironsand Jul 14 '13 at 2:54

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.