I created a test using grep , but it does not work in sed .
grep
sed
grep -P '(?<=foo)bar' file.txt
This works correctly by returning bar .
bar
sed 's/(?<=foo)bar/test/g' file.txt
I was expecting a footest as a conclusion, but that did not work.
footest
Note that most of the time, you can avoid lookbehind (or lookahead) by using the capture group and backlink in the replacement string:
sed 's/\(foo\)bar/\1test/g' file.txt
GNU sed does not support search statements. You can use a more powerful language such as Perl, or perhaps experiment with ssed , which supports Perl-style regular expressions.
ssed
perl -pe 's/(?<=foo)bar/test/g' file.txt
Source: https://habr.com/ru/post/1203657/More articles:How to permanently ignore a false result in violating SonarQube rules - sonarqubeCan I use the $ compilation in the Angular service directly on templateUrl instead of raw HTML or raw angular. Element? - angularjsassociative arrays in awk causing memory limitations - memoryLaravel, dump startup without access to Shell - phpDjango: getting specific columns from multiple tables - djangoPartialView angularjs controller not working - angularjsAwk code with associative arrays - the array does not seem populated, but without errors - associative-arrayloop optimization, passing parameters from an external file, naming array arguments in awk - arraysBuild multiple solution platforms at once? - c #Django: KeyError when retrieving multiple tables - djangoAll Articles