WarpZero RSS WarpZero@Twitter WarpZero@LinkedIn Michael Marth@Facebook Monday, 21-May-2012 01:50:53 EDT
   
warpzero.com

° Home
° News & Updates
° Howto & Knowledge Base
° External Resources
° Contact us
° Search
° Site Validated
° Site Map




Find data within files on unix and linux




This document should help provide the necessary information to assist in performing searches within text files on linux and unix systems.




  1. Replace the parameters in bold with your criteria.
    Note the trailing semi-colon ";" after the slash "\" slash and yes there is a space after the last curly bracket "}"

    find /directory -name \*.log -exec grep -l "string to find" {} \;

  2. Example 1: Search for an IP address

    find /log_filesystem -name \*.log -exec grep "172.16.3.50" {} \;

    Results are as follows:
    172.16.3.50 - - [06/Mar/2005:11:35:37 -0500] "TRACE / HTTP/1.0" 403 1078 "-" "-"
    172.16.3.50 - - [11/Oct/2005:21:53:46 -0400] "GET / HTTP/1.0" 200 13473 "-" "-"

  3. Example 2: Search for a string called Serial in the directory "/web_filesystem/"

    find /web_filesystem/ -name \* -exec grep -l "Serial" {} \;

    Results are as follows:
    /web_filesystem/site1/content/learning/index.html
    /web_filesystem/site1/content/learning/Serial-console.html
Linux Counter
Apache
IBM Canada
Cisco Systems
RedHat
Linux
 
 Published: Wednesday, 10-Nov-2010 05:15:18 EST