Use the FIND command non-recursively
Solved
noury
-
bill -
bill -
Hello,
does anyone know how to use the find command without descending into the directory tree?
does anyone know how to use the find command without descending into the directory tree?
7 answers
You use the option -maxdepth
--> all the files in the current directory.
Johan
Gates vous a donné les fenêtres.
GNU nous a donné toute la maison.
find . -name '*.c' -maxdepth 1 -type f
--> all the files in the current directory.
Johan
Gates vous a donné les fenêtres.
GNU nous a donné toute la maison.
I bring up the subject from his grave in case someone comes across it during a search.
In fact, there is a solution with prune:
find . \( -type d ! -name . -prune \) -o -type f -print
1) We indicate that directories that are not called "." are not traversed
2) We request the display of files
In fact, there is a solution with prune:
find . \( -type d ! -name . -prune \) -o -type f -print
1) We indicate that directories that are not called "." are not traversed
2) We request the display of files
And otherwise, under AIX, you just need to use the ls command without filters (the limitation of ls only appears with filters).
So ls -1 | grep TOTO to filter all files in the current directory that contain "TOTO"
or ls -1 | awk '/^TOTO.*$/' to filter all files in the current directory that start with TOTO (etc...)
=> no recursion
to delete (example with all files starting with TOTO:
ls -1 | awk '/^TOTO.*$/{system("rm -f " $0)}'
So ls -1 | grep TOTO to filter all files in the current directory that contain "TOTO"
or ls -1 | awk '/^TOTO.*$/' to filter all files in the current directory that start with TOTO (etc...)
=> no recursion
to delete (example with all files starting with TOTO:
ls -1 | awk '/^TOTO.*$/{system("rm -f " $0)}'
Hello
I have the same question but for AIX/Solaris/etc, that is to say not Linux!
-[min/max]depth does not exist.
Personally, I think it's impossible, but someone might have another opinion?
I have the same question but for AIX/Solaris/etc, that is to say not Linux!
-[min/max]depth does not exist.
Personally, I think it's impossible, but someone might have another opinion?