Searching multiple files on server

Discussion in 'Site & Server Administration' started by Devilfish, Dec 12, 2009.

  1. #1
    Hi folks,

    I'm having a problem with a few of my sites on the same server. I want to search all the files on my server for a url.

    Is there a tool or command that I can run that will search inside files and not just the file name?

    Thanks! :)
     
    Devilfish, Dec 12, 2009 IP
  2. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #2
    You could use something like this:

    find /dir/ \( -name "*.cgi" -o -name "*.php" \) -print0 | xargs -0 egrep -l 'text1|text2|text3' >> /root/report
    Code (markup):
    This looks in the /dir/ directory for cgi and php files, then, scans them for the text1, text2 or text3 phrases, and if a file contains any one of them, it list the file in the /root/report file. Just view the file after the command has finished.
     
    RHS-Chris, Dec 12, 2009 IP
  3. kailash

    kailash Well-Known Member

    Messages:
    1,248
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    190
    #3
    Which operating system have you installed on your server?

    Kailash
     
    kailash, Dec 12, 2009 IP
  4. Asako

    Asako Peon

    Messages:
    266
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    # updatedb
    -This will update the list of the file you have in your server

    # locate <filename>
    -it will list out all the file that have similar name this also including folder.
     
    Asako, Dec 14, 2009 IP