I want to grep a file, and I want to get all the lines that have a certain environment variable (to be exact, $PWD
).
Of course, using just
cat file | grep '/'$PWD'/'
is not working, since $PWD
contains slashes.
I am trying to figure out how to do it correctly, but I come up only with weird and over-complicated solutions. What's some simple way to do this?
$PWD
inside a file, why add the leading and trailing/
to search string?