Quote:
Originally Posted by Passions
Hi, I wanted to search for a line and delete it, but the string contains a variable with various number of forward /'s.
path=/some/tmp/directory/that/is/different/each/time
sed "/$path/d" file
won't work. I tried replacing the forward slash, but I believe that's only when searching for strings.
sed "&$path&d" file
sed "%$path%d" file
doesn't work. Any ideas?
|
Yep...precede the forward slash with a back-slash, like this:
sed "/\//d" file
should do it. The back-slash tells sed that the next thing is only a character, not any sort of 'special' thing (useful for things like $, ^, etc...)