Linux – find / grep command without searching mounted shares

findgreplinux

When I used the find command, I almost always need to search the local drives. But, I almost always have super large network shares mounted and these are included in the search. Is there an easy way to exclude those in the find command, grep and other similar commands? Example:

find / -name .vimrc

Best Answer

If you're using GNU find (as is used on most Linux systems), you'll want to use -mount:

find / -mount -name .vimrc

OS X/MacOS provides the local pseudo-fstype. This not in GNU find (fstypes recognized by GNU find).

Use the -fstype local option to find on MacOS:

find / -fstype local -name .vimrc

If you want to exclude only specific paths, you could use -prune:

find / -path "/path/to/ignore" -prune -o -name .vimrc
Related Question