I am a brand-new Linux mechanism user. Just how do I see a recursive brochure listing top top macOS Unix system? In Linux, how have the right to I get a recursive magazine listing?Introduction – If you favor to get the list, every directories and files recursively shot the complying with commands.

You are watching: What does recursive mean in linux

Tutorial details
Difficulty levelEasy
Root privilegesNo
RequirementsLinux and Unix-like OS
Est. Reading time3 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

*
*
From the above outputs, it is clear that running the tree dir1 provides a list of dir1 directory and also its subdirectories and also files. The base catalog is dir1. Then you have actually all the boy directroies. Every all the child directories have extr files and also directories (say cool directories), and so on. You deserve to use miscellaneous Linux commands going through each catalog recursively till it hits the finish of the brochure tree. In ~ that allude Linux commands come earlier up to a branch in the tree a go the exact same thing for any kind of sub-directories if any.

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

Conclusion

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.