You are watching: What does recursive mean in linux
|Requirements||Linux and Unix-like OS|
|Est. Reading time||3 minutes|
What is a recursive listing the files?
Recursive method that Linux or Unix command works v the consists of of directories, and also if a directory has subdirectories and files, the command functions on those files too (recursively). Say you have a magazine structure as follows:tree dir1
How to gain a recursive catalog listing in Linux or Unix
Try any type of one of the following command:ls -R : usage the ls command to get recursive directory listing on Linuxfind /dir/ -print : run the uncover command to view recursive magazine listing in Linuxdu -a . : Execute the du command to see recursive directory listing ~ above Unix
Let us see some examples to acquire a recursive brochure listing in Unix or Linux systems.
Linux recursive magazine listing command
Type the following command:ls -Rls -R /tmp/dir1
Linux recursive brochure listing using ls -R command.
Unix recursive brochure listing command
Since, no all execution of Linux, macOS, *BSD, and Unix-like system have -R alternative for the ls command. Try to use uncover command:find . -printfind /tmp/dir1 -printfind /tmp/dir1/ -print -ls
Recursive directory listing in Linux or Unix making use of the discover command
How to perform all files recursively in a directory
Our final instance uses the du command as follows:du -a .du -a /tmp/dir1/You can additionally use the tree command as follows:tree .tree /tmp/dir1/
Recursively working through files
It is feasible to operation command recursively top top files. The syntax is:my-command-here $(find /dir/ -name "pattern" -print)rm -i $(find /home/nixcraft/ -name "*.bak" -print)Of course, your have the right to run command using uncover itself:find /dir1/ -name "pattern" -print -exec command ;find /dir1/ -name "pattern" -print -exec command ;find /dir/2/foo/bar -name "*.pl" -exec rm -rivf ;find /dir1/ -type f -name "*.doc" -exec rm -fiv ;## find paper recursively and delete lock ##find /dir1/ -name "pattern" -print -deleteSee “Linux / Unix: Find and Remove files With One Command ~ above Fly” for an ext info.
See more: How To Remove Melted Plastic From Oven Rack ? How To Clean Melted Plastic From Your Oven
No ads and tracking join my Patreon to support independent contents creators and start reading latest guides: sign up with Patreon ➔
You learned just how to perform all files recursively in a directory under Linux, macOS, *BSD and also Unix-like operating device using the ls, du, and find commands.