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
d41d8cd98f00b204e9800998ecf8427e ./12/1.txt
d41d8cd98f00b204e9800998ecf8427e ./1
d41d8cd98f00b204e9800998ecf8427e ./11.txt
and the given word equal to "./1" I would like to print only the line:
717c41ff4049b0e8cbdc7ec7e49ad021 ./1
I'd simply use grep, with "$" anchor added at the end, 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.
Edit: The word is passed as a variable not a fixed string.