whereis, pipline and ls

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).

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

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.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply