Reputation: 1767
I have little problem when I try pass a variable (which contain a path) to sed. It work well if variable didn't contain "/" character. simple code from script for example:
sed "$1/d" $conf
file $conf contain next lines
aaa
/bbb
.ccc
When I try put:
scriptName aaa
all work well. But if i put
scriptName /bbb
I got
sed: can't find label for jump to `bb"/d
message. Also I try
scriptName \/bbb
scriptName //bbb
Last falls with
sed: -e expression #1, char 9: unknown command: `/'
How work with sed is I take path from variable and it contain special characters?
Upvotes: 1
Views: 1111
Reputation: 123538
There are two ways to work around the issue:
Escape the /
in your pattern:
sed '/\/bbb/d' filename
Supply a different delimiter, but the delimiter would need to be escaped (not the /
in the pattern):
sed '\#/bbb#d' filename
Upvotes: 2