I'm writing a bash script and I would like to print all lines containing a word, but only if it is at the end of a line. So given a file like this:
d41d8cd98f00b204e9800998ecf8427e ./12/2.txt
d41d8cd98f00b204e9800998ecf8427e ./12/1.txt
717c41ff4049b0e8cbdc7ec7e49ad021 ./1
and the given word equal to "./1" I would like to print only the line:
717c41ff4049b0e8cbdc7ec7e49ad021 ./1
I'd simply use grep for that, but my problem is that the words may contain dots so I need to have the -F
option, but then I am unsure how to secure that the printed lines contain the word at the end of the line, as I can't use line anchors. What seems to be working is using grep -Fw
, but I am not convinced that this exactly what I'm looking for as -w
option means --word-regexp
and I don't want regex. Does the-F
option disable the regex matching in -w
? Is there a better way to achieve my goal?