Friday, June 11, 2010

How to: UNIX List just directories or directory names

Display or list all directories

Type the following command:
$ ls -l | grep `^d'

You have current dir containing set of directories which contain files.
One file can reside in many directories.
Write script which returns number of unique file names in
all the subdirectories of a current dir.

ls -R | grep -v "^d" | sort -u

Display or list only files

Type the following command:
$ ls -l | grep -v `^d'

No comments:

Post a Comment