I want to write a command to display all the lines in a given file that end with a ";" or a "." character.

Why does this not work?

grep ".';' | .'\.'" filename
link|improve this question

I fixed your titles so they were actually meaning something. It would be great – if you post a question – to make your title really specific about what you want to do, not "Unix grep". – slhck Oct 4 '11 at 7:52
feedback

1 Answer

up vote 4 down vote accepted
grep "[;.]$" list-of-files

This matches any line which contains either ; or . followed by the end of the line.

link|improve this answer
.. how does this work ? – ricedragon Oct 4 '11 at 3:08
@ricedragon it's regex notation. [abc] means a or b or c. $ means match end of line. play with regex coach and see regular-expressions.info and grep -P is a bit more flexible. – barlop Oct 4 '11 at 4:04
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.