You are here: Articles > UNIX > UNIX

 See more articles about "UNIX "

Recursive grep

 

This tip is for grepping a pattern even in the sub-directories of a particular directory in addition to the files in the current directory.

Since grep -R <> <> is not available on all flavors, this can be really helpful.

The command is as follows :-



find <path> -name <filenamepattern> | xargs grep <searchstring>





The arguments are self-explanatory.

The output of find will be xarg'ed to the input of grep

and these will be searched for searchstring.

 

Also see ...

Kill the undesired UNIX processes in one go
H3This recipe is useful when one wants to kill all the processes belonging to one user or having a particular regular expression in the process name. One can use different options of "ps" and "grep" to kill the undesired process(es)./H3PThe following is the general syntax of this recipe b

Send HTML formatted mail from Unix using Sendmail
H3I have used this quite a bit and it works great for me. We're on an HP box running Unix 11.11. You can embed javascripts, css, etc. Pretty cool stuff. /H3Pdiv class="code"&40; br /echo "From&58; you@your_company.com" br /echo "To&58; you@your_company.com" br

UNIX: Shortcut to create a backup copy of a file
H3Copy and rename a file in a shorter step than the normal cp file file.bak/H3PIf you have a file named foobar and you want to make a backup copy named foobar.bak you could do br / br /div class="code"cp foobar foobar.bakP br /but what if the file has a long name, and you have

Place and manage tasks or jobs in the background from the comand line
H3Managing tasks or jobs from the command line or terminal is easy in unix flavors once you know the simple commands./H3PUnix, like other modern operating systems, can easily run multiple tasks at once. If you running from the command line or terminal, it is not obvious how to do this or mana

Unix/Linux: Easily find or search files or directories
H3Newbie unix guys like me need to know these kinda things. This explains how to find a file or directory from the command line. /H3PYeah, it's the unix version of dos's span style="font weight: bold"dir/s/span br /I'm no unix guru, but maybe this will help somebody. br / br /W