Reputation: 453
I have search string like && !this.peekStartsWith('//')
and want to replace with blank space .
I have tried
sed -i 's/&& !this.peekStartsWith('\/\/')/ /g' dist/vendor.bundle.js
but, getting an error like
bash: !this.peekStartsWith: event not found
Can anyone help to work around this?
Upvotes: 0
Views: 990
Reputation: 41460
I do only get this to work when escaping the !
sed "s|&& \!this\.peekStartsWith('//')| |g" file
Example file
cat file
some data&& !this.peekStartsWith('//')more data
test
sed "s|&& \!this\.peekStartsWith('//')||g" file
some datamore data
sed "s|&& \!this\.peekStartsWith('//')| |g" file
some data more data
sed "s|&& \!this\.peekStartsWith('//')|***|g" file
some data***more data
Upvotes: 1
Reputation: 133770
I could reproduce the error. You need to set your history
off as follows first, since you have !
in your text which you are placing inside sed
command, is causing this error.
set +o history
Now When you run sed
command as follows, it works well.
echo "test && !this.peekStartsWith('//') bla" | sed "s|&& !this\.peekStartsWith('//')||g"
test bla
To start history
again you could use:
set -o history
Upvotes: 4