Wednesday, June 2, 2010

sed: for the text between matching pattern

sed -ne '/IC/,/EI/p' country-codes.txt where IC is the first pattern and IE is the last for the file having country codes

file:country-codes.txt
GY,Guyana
HA,Haiti
HO,Honduras
HU,Hungary
IC,Iceland
IN,India
ID,Indonesia
IR,Iran
IZ,Iraq
EI,Ireland
IM,Isle of Man
IS,Israel
IT,Italy

command: sed -ne '/IC/,/EI/p' country-codes.txt
IC,Iceland
IN,India
ID,Indonesia
IR,Iran
IZ,Iraq
EI,Ireland

No comments:

Post a Comment