Using "find" non-recursively?

You can do that with -maxdepth option

/bin/find /root -maxdepth 1 -name '*.csv'

From man find

-maxdepth levels

Descend at most levels (a non-negative integer) levels of directories below the starting-points.

-maxdepth 0

means only apply the tests and actions to the starting-points themselves.


With standard find:

find /root ! -path /root -prune -type f -name '*.csv'

This will prune (remove) all directories in /root from the search, except for the /root directory itself, and continue with printing the filenames of any regular file that matches *.csv.

With GNU find (and any other find implementation that understands -maxdepth):

find /root -maxdepth 1 -type f -name '*.csv'

Tags:

Shell

Find