Skip to content
Advertisement

sed removes one string in one file

I’m trying to remove one string in one file by using:

sed -i -e '/example/' test.txt

But I’ve got the following error:

sed: -e expression #1, char 6: missing command

What is it missing and why?

Thanks!

Advertisement

Answer

/example/ is an address which tells sed where to run commands – on a line containing the string example. You didn’t specify any commands.

This is a commnand that replaces the string example with an empty string:

's/example//'
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement