cancel
Showing results for 
Search instead for 
Did you mean: 

grep the contents

 
Highlighted
Advisor

grep the contents

Hi all,

I have a file (T1.txt) which contains below information, i just need to get all "/a1" information and it's Number of records.
Please help me to get this output -Thanks.

OUTFILE 1: /a1
Number of records = 1319
OUTFILE 2: /a2
Number of records = 1319
OUTFILE 3: /a1
Number of records = 1561

5 REPLIES 5
Highlighted
Regular Advisor

Re: grep the contents

If there is only 1 /a1 ref and its at the top in the file then a simple cat T1.txt | head -2 would work.
Highlighted
Regular Advisor

Re: grep the contents

This may be more useful...

cat T1.txt | awk '/\/a1/, /Number/ {print $0}'
Highlighted
Acclaimed Contributor

Re: grep the contents

Hi:

# perl -ne 'm{/a1}...{Number} and print' file

Regards!

...JRF...
Highlighted
Advisor

Re: grep the contents

Thanks for N Ward your solution is ok.
Highlighted
Acclaimed Contributor

Re: grep the contents

Hi (again):

If you are satisfied with the answers you received, please assign points to say "thanks" and lead others to a solution for their problems:

http://forums11.itrc.hp.com/service/forums/helptips.do?#28

...JRF...