mount |awk '{print $3}' --> list of mount points

find "list of mount points"  -name  "aaa" -print

How can I redirect the result from previous line into find command as searching directory?

I would like to have it done in one line:

mount |awk '{print $3}' | find "converting pipe result to a variable as directory" -name "aaa" -print

Possible to make it work this way?

  • This is probably not what you want on linux, since you will be using find on psuedo-filesystems such as proc and sysfs.
    – jordanm
    Jan 8, 2013 at 21:20

2 Answers 2


Possible to make it work this way?

Yes, with xargs:

mount |awk '{print $3}' | xargs -I {} find {} -name "aaa" -print

You can even make it search your hard drives in parallel, if you add -P n after xargs for maximum n simultaneous processes (this is a GNU extension).


You're looking for command substitution: substitute the output of a command into a command line.

find $(mount |awk '{print $3}') -name "aaa" -print

This only works if the mount points don't contain any whitespace or *?\[. This restriction is rarely a problem for mount points (but do make sure that you don't have mount points with space characters — the awk command would not parse them correctly anyway).

You need to tell find not to traverse mount points, otherwise find / already traverses your whole system. Pass the -xdev option.

find $(mount |awk '{print $3}') -xdev -name "aaa" -print

Note that you should probably not run find on all the mounted filesystems, as there are filesystems for internal system use that can be quite large and contain a lot of files that you don't have permission to read (causing spurious error messages). Instead of getting the list of filesystems from mount, get it from df, which omits some of these filesystems.

find $(df -P |awk 'NR != 1 {print $6}') -xdev -name "aaa" -print

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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