grep the string lines from the file

2

csv file.

1,2,3,abc
2,3,4,def
3,4,5,abc
3,4,2,def
6,7,9,abc.

I need to read that file and get the lines of file containing abc.

manu2711

Posted 2014-01-24T15:38:08.827

Reputation: 21

Answers

5

grep ",abc" file.csv

Sounds enough? Or to be sure it finishes with abc:

grep ",abc$" file.csv

(in this case the last one in your example won't match due to the full stop at the end)

fede.evol

Posted 2014-01-24T15:38:08.827

Reputation: 1 718

2+1 for the correct pattern. Don't need cat though: grep ",abc" file.csv. Another way to match just the word "abc" and not "Aabc" or "abcd" is to use word anchors: '\<abc\>' – glenn jackman – 2014-01-24T15:47:42.510