I have a file that has a single line with a lot of !
characters. I want to remove all of the !
characters.
I tried this:
sed s/!// myfile
and this:
sed 's/!//' myfile
and this:
sed 's/"\!*"//' myfile
But they all just print out all of the "!".
I must be missing something obvious. Any ideas?
Add a
g
to your regexp, for global replacement. Otherwise, only the first occurrence will be substituted:Try this:
Don't forget poor old
tr
tr only operates on stdin, so you have to pipe data into it.
add the g at the end in order to replace all occurances.
sed 's/"!*"//g' myfile
You have to specify you want every occurence removed:
sed 's/!//g' myfile
Note the
g
, which mean 'greedy'.Without the 'g', you only have the first '!' removed