Sed search for variable and delete entire line, but variable contains forward /'s
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? |
Quote:
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...) |
If an alternative to the usual '/' delimiter is used in a sed line range the first one has to be escaped with a '\'. Try:
sed "\%$path%d" file |
All times are GMT -5. The time now is 03:50 PM. |