Reputation: 24373
I have a file with lines like this:
bear/forest/\AAA mountains/fish/
fish/\AAA stream/river/\AAA shrimp/
llama/mountains/
I want to delete any text appearing between 2 /
's, where \AAA
appears, e.g., the above would become:
bear/forest/fish/
fish/river/
llama/mountains/
AAA
always appears after the first /
symbol.
I have tried to make a find and replace, matching the pattern /\AAA*/
and replacing it with /
, but this did not work:
sed -i -r 's/\/\\AAA*\//\//g' file.txt
I have GNU sed version 4.2.1.
Upvotes: 0
Views: 979
Reputation: 241758
Just remove everything between /\AAA
and /
. Using an alternative character to separate the patterns improves readability, if the pattern or replacement contain /
:
sed 's,/\\AAA[^/]*/,/,g'
Upvotes: 1