Skip to main content

Posts

Showing posts from April, 2011

UNIX Find A File Command

Find all perl (*.pl) files in current directory: $ find . -name '*.pl' The . represent the current directory and the -name option specifies all pl (perl) files. The quotes avoid the shell expansion and it is necessary when you want to use wild card based search (without quotes the shell would replace *.pl with the list of files in the current directory). To list only files and avoid all directories $ find . -type f -name '*.pl' Above command will only list files and will exclude directories, special files, pipes, symbolic links etc. Search all directories Search file called httpd.conf in all directories: $ find / -type f -name httpd.conf Generally this is a bad idea to look for files. This can take a considerable amount of time. It is recommended that you specify the directory name. For example look httpd.conf in /usr/local directory: $ find /usr/local -type f -name httpd.conf Execute command on all files Run ls -l command on all *.c file...