-1

When I type:

whereis boost

it shows:

/usr/include/boost

Now I want to list all the files in this directory, so I type:

whereis boost | ls

But it only shows the files in the current working directory. Is there anyway to list all the files more quickly following the idea above (the way can be different but the idea is I want to quickly have a glimpse at a directory which I find with whereis, locate or something like that).

  • @LongHDi The first item listed on How to Ask is a suggestion that you first thoroughly search for an answer before posting here. This could (should) include reading relevant manuals, though I don't think we could reasonably expect you to know to look in sh(1) if you're new. Command substitution is the answer, but I'm going to casually mention xargs – Fox May 10 '17 at 8:28
3

ls doesn’t take its arguments from its standard input (which is how a pipe passes data into a process), but from its command line.

ls $(whereis boost)

will take the output of whereis boost and use it as arguments for ls, giving the result you’re after. This is known as command substitution.

| improve this answer | |
  • Thank you! I have very little experience with Linux command line so I hadn't known the command substitution until you showed me. – Long HDi May 10 '17 at 7:06

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