Wednesday, December 29, 2010

Using "ls" and "find" command how to display only directories..?

Following commands list only directories in the current directory.

1. #ls -l | grep ^d

2. #ls -d */

3. #find -type d
Ex: #find /tmp -type d <-- This command shows all the directories with in the /tmp directory.

Want only files to be listed.. use 1. #ls -l | grep -v ^d

2. #find -type f
Ex: #find /tmp -type f <-- This command shows all regular files with in the /tmp directory.

No comments: