The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Search Text in files via SSH

Discussion in 'General Discussion' started by Tymsah, Aug 11, 2008.

  1. Tymsah

    Tymsah Well-Known Member

    Joined:
    Apr 6, 2007
    Messages:
    151
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Hi,

    i want to search some word in Text files in SSH
    which command ?

    Regards,
    Tymsah
     
  2. hydra

    hydra Well-Known Member

    Joined:
    Mar 26, 2008
    Messages:
    102
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Amsterdam, Netherlands
    grep searchtext /path/filename
     
  3. shaheen_ak28

    shaheen_ak28 Registered

    Joined:
    Aug 13, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Cochin, India
    grep -ir searchkey *

    The above command will search for the word within all files under that directory recursively.
     
  4. ChrisRHS

    ChrisRHS Well-Known Member

    Joined:
    Jul 12, 2006
    Messages:
    292
    Likes Received:
    5
    Trophy Points:
    18
    The following searches a directory and places the name of the file that gets found in the /root/found file

    find /directory -exec grep -l 'your text here' {} \; > /root/found
     
Loading...

Share This Page