Input Redirection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kaarthikeyapreyan
    New Member
    • Apr 2007
    • 106

    Input Redirection

    I have a small problem with the input redirection.

    to search for a particular pattern in all files i have used this command

    Code:
    find $dir -type f -print | xargs grep -E -n -w <pattern> | tee my res.txt
    this would give me the output in the format

    filename : line number : matching line

    I would like to have something like this in my output file

    filename : line number : matching line : match

    the solution that i wondering was that i would redirect my output to another command

    Code:
    grep -o <pattern>
    so my new structure would look like

    Code:
    find $dir -type f -print | xargs grep -E -n -w <pattern> | tee -a my res.txt | grep -o pattern | tee -a myres.txt
    my the output from tee has to be redirected in a correct way which would make this code to work fine.
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Ok, I will be the first to ask it.... is there a question in all of that that you would like to know the answer to?

    Comment

    • kaarthikeyapreyan
      New Member
      • Apr 2007
      • 106

      #3
      Yes there is ...

      I would like to have something like this in my output file

      filename : line number : matching line : match
      the redirection is not proper to get the desired output
      so what would be the best wat to use the redirection to get my desired output

      so my new structure would look like
      Code:
      find $dir -type f -print | xargs grep -E -n -w <pattern> | tee -a my res.txt | grep -o pattern | tee -a myres.txt

      Comment

      Working...