Reputation: 942
I want to exact match the below line in a file
#dtoverlay=piscreen,drm
I have tried
grep "\#dtoverlay=piscreen,drm\" /boot/config.txt
but this also returns a match for
##dtoverlay=piscreen,drm
Also tried with a -w, but it also matches ##dtoverlay=piscreen,drm
grep -w '#dtoverlay=piscreen,drm' /boot/config.txt
##dtoverlay=piscreen,drm
Upvotes: -1
Views: 52
Reputation: 12425
Use this regex, where ^
and $
match the beginning and the end of the line, respectively:
grep '^#dtoverlay=piscreen,drm$' /boot/config.txt
See grep
manual:
Anchoring
The caret
^
and the dollar sign$
are meta-characters that respectively match the empty string at the beginning and end of line.
Upvotes: 1