I tried to find a file lives within curent directory only, and typed
$ find . -depth 1 -ls -name *.ini
But it gave me,
find: paths must precede expression: 1
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
How'd I do it correctly ? Thanks in advance.
The option -depth
does not take a parameter. It means that find should use a depth first method for walking the directory tree. Perhaps you are looking for -maxdepth
(GNU find only)?
--
Note: In BSD find
also supports -depth
with a parameter and then it has a whole different meaning, which is a bit confusing..
Probably you want to prevent it from recursion?
Then there is the following work-around for a Unix find
find . \! -name . -prune -name "*.ini" -ls
A GNU find takes
find . -maxdepth 1 -name "*.ini" -ls
The *.ini
is to be evaluated by the find not the shell, therefore must be quoted. The -ls
should follow it, so depends on the previous condition.
1 Like