Skip to main content
Linux AdministrationMediumSingle Choice

Linux Administration Question

Statement

Which grep command will print only the lines that do not end with a / in the file foo?

#grep#regex#inverted-match#line-end-anchor
A

grep '/$' foo

B

grep '/#' foo

C

grep -v '/$' foo

Correct
D

grep -v '/#' foo

Resolution & Explanations

The -v option inverts the match. The regex /$ matches the / character at the end of a line ($). Combined, it prints lines that do NOT end with a slash.