-4

I have a text file which looks like :

12345  12-02-2013 05:12:23:234 searchPeople service called by the follwoing input :
       name      : Tom
       id        : 12345
       regd_no   : REGD1234
12346  12-02-2013 05:12:23:240 response obtained from searchPeople service

I need to search multiple patterns : "name : Tom" and "regd_no : REGD1234" with grep.

Can anyboy help me please??

susamn
  • 1
  • 1

1 Answers1

1

Since this is your first question, try:

$ grep 'name\|regd_no' input.txt
       name      : Tom
       regd_no   : REGD1234

But in the future, please read the FAQ...

update

grep generally works on one-line at a time, but since your example-file is short, one approach to solve your problem is this:

$ tr -d '\n' < input.txt | grep -o 'name\s*:\s*Tom\|regd_no\s*:\s*REGD1234'
name      : Tom
regd_no   : REGD1234
Community
  • 1
  • 1
Fredrik Pihl
  • 44,604
  • 7
  • 83
  • 130
  • This is true if name=Tom OR regd_no=REGD1234. If i want to do name=Tom AND regd_no=REGD1234 – susamn May 08 '13 at 19:40