Recursive File & Directory Listing in Unix [Consumer]

by on December 10, 2009

in consumer

If you need to see everything that’s listed under a specific directory under unix, you have 2 options. (That I know of)

ls -R (And whatever other options you like)

This will create a recursive listing of all files and directories under the location you are at when you invoke this command.

find . -print

I actually found that I like this one better because of how it formats the output, making it a tiny bit easier

Output examples after the break:

tetsu% ls -R
.:
#.cshrc#     hw2.pl       perlsource/

./perlsource:
#hw2.pl#   test.pl
% ls -alR
.:
total 18
-rw-r–r–   1052 Feb  6  2007 #.cshrc#
drwxr-xr-x   512 Feb 26  2007 ./
drwxr-xr-x  29 root     root        1024 May 12  2009 ../
-rw-r–r–   1098 Feb  6  2007 .cshrc
drwxr-xr-x   512 Feb  6  2007 .emacs.d/
-rw-r–r–   669 Jan  4  2007 .login
-rw-r–r–   0 Feb 26  2007 hw2.pl
drwxr-xr-x   512 Feb 26  2007 perlsourc

./.emacs.d:
total 6
drwxr-xr-x   512 Feb  6  2007 ./
drwxr-xr-x   512 Feb 26  2007 ../
drwxr-xr-x   512 Feb 26  2007 auto-save

./.emacs.d/auto-save-list:
total 4
drwxr-xr-x   512 Feb 26  2007 ./
drwxr-xr-x   512 Feb  6  2007 ../

./perlsource:
total 6
-rw-r–r–         0 Feb 26  2007 #hw2.pl#
drwxr-xr-x      512 Feb 26  2007 ./
drwxr-xr-x      512 Feb 26  2007 ../
-rw-r–r–          165 Feb 14  2007 test.pl
%

OR

% ls -R
.:
#.cshrc#     hw2.pl       perlsource/

./perlsource:
#hw2.pl#   test.pl
%

~ ~ ~

I like the find option because it seems to not need to be scrutinized too hard to understand what you’ve got:

% find . -print
.
./.login
./.cshrc
./hw2.pl
./perlsource
./perlsource/test.pl
./perlsource/#hw2.pl#
./.emacs.d
./.emacs.d/auto-save-list
./#.cshrc#
%

Now you know!

Related posts

Leave a Comment

Previous post:

Next post: