Shell Script for Extracting all the lines containing a particular string

This we can do in many ways using AWK, SED, PERL etc

Ex: Printing all the lines containing aaa in a file abc.txt
Using AWK:
awk '/aaa/{print}' abc.txt

Using PERL:
 perl -wn -e 'print if /aaa/' abc.txt


This can be written into another file by using redirection as
awk '/aaa/{print}' abc.txt  > tmp.txt

perl -wn -e 'print if /aaa/' abc.txt > tmp.txt


Regards
G K Reddy Chinthalapudi

Comments

Popular posts from this blog

LAPD vs LAPDm

LAPD vs LAPDm(Technical)