2

I have a file like this-

Asia
Europe
Africa

I want to search for word Europe and insert '#' in front of it which should appear like this-

Asia
#Europe
Africa

I tried:

sed -e 's/"Europe"/"#Europe"/g' $file

Also:

sed -r 's/"Europe"/"#Europe"/g' $file > $tmp`
mv $tmp $file

But it is not overwriting that particular line only,infact updating he file with a single line only like this:

#Europe
4

1 回答 1

2

这可能对您有用(GNU sed):

sed -i 's/^Europe/#&/' file
于 2013-07-14T20:52:11.423 回答