Defcon-1-Logo

           [Home]    [FBSD Articles]    [Scripts Corner]    [Contribute]    [Search]    [FBSD Links]    [Files]

About Us

FreeBSD Articles
  *Hardware
  *Networking
  *Security
  *Software
  *X Windows


Files / Scripts
Newbies Corner
Tech. Talk
Tips and Tricks


FreeBSD Links

Articles in other
Languages :
  *French Articles
  *Spanish Articles

Want to Help ?
 
   Click Here

Email Users5

Search:
 

 


FreeBSD Search:


 

 

Powered-By-Apache-Logo

Using GREP in Unix

 Well believe it or not GREP is your friend, it will save you lots of time, as long as you use it wisely. This article will hope to show you how to use it, and help you get the full use out of it. 

 grep can be used to do a search for a word or pattern of words, with a set of characters such as a file. When using grep to search files, an example would be, any matches to the word or characters you specify. Then the findings are printed as a complete line in which the grep found in the files in the file which the search occurred.

  Example : Lets say you have a file called chuckie.txt and you are looking for the word FreeBSD within that file you would do.

   To search for any listing of 'freebsd', you could type:

           grep freebsd chuckie.txt
    

   Once it finds something, it would show the text within the file on the screen.


  grep is case sensitive by default, If you wanted to find all chances of the word freebsd in the chuckie.txt files you would do the following, by adding a -i to the command line, shown below.

            grep -i freebsd chuckie.txt
    

  Lets say we have several .txt files that we wish to search for the word freebsd, to do this without having to open each file you would do the following command line.

            grep -i freebsd *.txt
    

  Ok, lets say we are looking for dog and want to see every file shown on the machine that has the word dog listed in it, to do this you would do the following. First you will need to goto the root directory, to do this.

            cd \
            grep -R dog * |more


  The |more at the end will stop the text one screen worth at a time, so you can read it, otherwise it might go by so fast you couldn't read the screen, thus missing what you might be looking for.
 

 GhostRdr  version 10.30.99

Email Us

ghostrdr@defcon1.org

This site cannot be duplicated without permission

© 1998 - 2010 Defcon1, www.defcon1.org. Copyrights for all materials on this web site are held by the individual authors, artists, photographers or creators. Materials may not be reproduced or otherwise distributed without permission of www.defcon1.org and the content's original author.