views:

38

answers:

2

I have got a file with following format.

1234, 'US', 'IN',......
324, 'US', 'IN',......
...
...
53434, 'UK', 'XX', ....
...
...
253, 'IN', 'UP',....
253, 'IN', 'MH',....

Here I want to extract only those lines having 'IN' as 2nd keyword. i.e.

253, 'IN', 'UP',....
253, 'IN', 'MH',....

Can any one please tell me a command to grep it.

+2  A: 

grep -E ^[^,]*,\ \'IN\',.+\$ FILENAME

That should do the trick!

Delan Azabani
+2  A: 

This works:

egrep "^[0-9]+, 'IN'"
Hasturkun