Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    166
    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:
    68
    Location:
    Amsterdam, Netherlands
    grep searchtext /path/filename
     
  3. shaheen_ak28

    shaheen_ak28 Registered

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

    The above command will search for the word within all files under that directory recursively.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. ChrisRHS

    ChrisRHS Well-Known Member

    Joined:
    Jul 12, 2006
    Messages:
    292
    Likes Received:
    5
    Trophy Points:
    168
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice