简体   繁体   中英

How to grep lines having specific format

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. ie

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

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

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

That should do the trick!

这有效:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM