Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Posts
    6

    Unanswered: Search text in all files in directory

    I am attempting to search all files in the current for searchText. Then display the filename, line number, and entire line.

    What I am thinking of doing is:

    grep il "searchText" > tempFile

    then look through the temp file and extract each file name, and use another grep or maybe an awk statement to display the filename, line number, and entire line.

    I am sure this is a round-about way of doing things. I am attempting this in a Bourne shell so if anyone can help me thank you.

    -Sweetness

  2. #2
    Join Date
    Jun 2004
    Posts
    20
    grep -rn "search pattern" * > outfile

    r- recursive
    n- line number

    Out put will be like this
    FileName: lineNumber: line

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •