I've got problem with removing part of string between two patterns with sed. I've always got last PATTERN-2 in line:test.txt:PATTERN-1xxxxPATTERN-2aaaPATTERN-1xxxxPATTERN-2fffPATTERN-1zzzzPATTERN-2gggPATTERN-1zzzzPATTERN-2PATTERN-1xxxxPATTERN-2bbbcmdsed 's/PATTERN-1.*PATTERN-2//g' test.txtthe result of above isaaabbbbut I would like to haveaaafffgggbbbIs possible to find PATTERN-2 which is closest to PATTERN-1?
sed and remove string between two patterns
sed;regular expression