Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

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?

share|improve this question
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 '13 at 21:20

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

share|improve this answer

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
share|improve this answer

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.