Saturday, May 7, 2022

[SOLVED] sed: just trying to remove a substring

Issue

I have a file with this content:

foo: bar1
foo: bar2
foo: bar3
foo: bar4
foo: bar5

I want to remove the chains "foo: " so the file remains:

bar1
bar2
bar3
...

I'm trying it with:

$ sed 's/foo: /' file.txt

but it says:

sed: -e expression #1, char 15: unterminated `s' command

Any help?

Javi


Solution

You need to:

$ sed -r 's/^foo: //' file.txt


Answered By - aefxx
Answer Checked By - Marilyn (WPSolving Volunteer)