getting error "/bin/sed: -e expression #1, char 13: extra characters after command"
Hi,
I am trying to delete a line from a file. This line contains '#' and '/' like below. #element /abc/xyz/mtn... When I am using a sed to delete the command, I am getting extra characters after command. The command I used is as below. /bin/sed -i '/#element /abc/xyz/mtn.../d' <file> I tried using a different delimiter as below. The error is gone but the line is not deleted. sed -i '/\($x\)/d' <file> ( Here x="#element /abc/xyz/mtn...") Please help me out Thanks |
Please us [code] and [/code] tags:
[code] Code:
sed '/^#element \/abc\/xyz\/mtn...$/d' |
Hi,
Thanks for the reply. But I am using the string '#element /abc/xyz/mtn...' as variable and using that variable in the sed command. What can I do in that case? |
Help us to help you. Provide a sample input file (10-15 lines will do). Construct a sample output file which corresponds to your sample input and post both samples here. With "Before and After" examples we can better understand your needs and also judge if our proposed solution fills those needs.
Daniel B. Martin |
I wouldn't use sed for this. How about awk?
Code:
FILTER='#element /abc/xyz/mtn...' |
I wouldn't use sed for this. How about awk?
Code:
FILTER='#element /abc/xyz/mtn...' |
Quote:
Daniel B. Martin |
(The problem is that the 'filter' part might contain grep meta-characters)
|
Quote:
|
(The problem is that the whole line should match as in ^filter$)
|
Quote:
|
Quote:
Code:
x="#element /abc/xyz/mtn..." Code:
x="#element /abc/xyz/mtn..." Code:
xmod="$(echo "$x" | sed 's;[[/^$.*\\];\\&;g')" |
All times are GMT -5. The time now is 07:33 AM. |