UNIX recursive directory listing

Contributor Icon Contributed by Rex  
Tag Icon Tagged: UNIX  

Listing the contents of a directory and all subdirectories, a recursive listing, is sometimes useful. This recipe describes some techniques for listing files recursively


The simplest method of performing a recursive directory listing is with the ls command:

ls -R

ls -lR

The first is a short listing (filename only) and the second version shows a long listing (the output of ls -l but recursive). These commands will perform the recursive listing from the current working directory. Adding a directory name to the end of the commands will start the listing in that directory.

The find command performs recursive searches by default. To duplicate ls -R, use:

find . -print

The -print option is the default in many versions of find, so just ‘find .’ will often work. The find command is extremely powerful and is worth reading a few recipes to learn. Recipes like this.

 

1 Comment -


  1. Charles said on September 30, 2011

    This is useless. What’s the equivalent of “dir *.txt /s” in unix using ls?

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -