This question already has an answer here:
- sed whole word search and replace 5 answers
Please help me in solving the below issue. I have a file:
mat rat
mat dog
mat matress
I need to display
rat
dog
matress
I have coded with sed
command to display the output: sed "s/$up//g"
($up
will contain mat
) . But using this command, I am getting the output as
rat
dog
ress
What do I do to resolve this?.
Please help.
g
suffix so the code only drops the leadingmat
. There's also a question whether the pattern to be excised should bes/^mat //
with the trailing space; that won't affect thematress
(ormattress
). – Jonathan Leffler Mar 15 at 5:18