Home arrow Programming Fundamentals arrow SED: A powerfull Text Manipulator in linux/unix

Language Translator

Hacking Zone

Hacking Tools
Attacking

Configure Windows

Windows Configuration

Mix Tutorials

Asterisk
Website Building

Novels

Mix Novels

Human Personality

Body Language
SED: A powerfull Text Manipulator in linux/unix Print E-mail

SED: A powerfull Text Manipulator in linux/unix

 

                    You need to use find command which is used to search files and directories under UNIX and Linux like operating systems. You can specify criteria while search files. If no criteria is set, it will returns all files below the current working directory. find also supports regex matching and other advanced options.

Examples

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 files to get extended information :


$ find . -name "*.c" -type f -exec ls -l {} \;


You can run almost all UNIX command on file. For example, modify all permissions of all files to 0700 only in ~/code directory:


$ find ~/code -exec chmod 0700 {} \;


Search for all files owned by a user called payal:


$ find . -user
$ find . -user payal


Read find command man page for detailed information:


$ man find

 





Digg!Reddit!Del.icio.us!Live!Facebook!Slashdot!Technorati!StumbleUpon!Newsvine!Fark!Blogmarks!Yahoo!BlogMemes!FeedMeLinks!
Comments
Add NewSearch
Only registered users can write comments!

Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved.

 
< Prev   Next >
Your Ad Here

RSS socialnet

Add to MyYahoo!
Subscribe in NewsGator Online
Add to Newsburst
Add to Google
Add to My AOL
Add to Pluck
Subscribe in FeedLounge
Add to Windows Live
Add to NetVibes
Subscribe in Rojo
Subscribe in Bloglines
Add to MyMSN
Add to Plusmo for your cellphone
Add to PageFlakes
Add to Technorati
Add to BlinkBits
Interactive world maps for websites