sed '/Working file:/ N ; s/\n/PLACEHOLDER/' changelog.txt |
grep -v 'PLACEHOLDER===' |
sed 's/PLACEHOLDER/\n/
pode, de fato, ser encurtado para:
$ sed '/Working file:/{N;/===/d}' changelog.txt
Working file: modifiedfile1.h
----------------------------------
revision 1.3
Fixed some bug
================
Working file: modifiedfile2.h
----------------------------------
revision 1.1
Added some feature
================
Working file: unmodifiedfile3.h
- Para remover todas as linhas que contenham
Working file:
e a linha seguinte, se contiver===
, bem como a linha final, se contiverWorking file:
Obrigado @ilkkachu pela sugestão. Se o padrão precisar ser combinado no início da linha, use ^Working file:
$ cat ip.txt
Working file: 123
================
Working file: f1
----------------------------------
revision 1.3
Fixed some bug
================
Working file: abc
================
Working file: file
----------------------------------
revision 1.1
Added some feature
================
Working file: xyz
$ sed '/Working file:/{N;/===/d}' ip.txt | sed '${/Working file:/d}'
Working file: f1
----------------------------------
revision 1.3
Fixed some bug
================
Working file: file
----------------------------------
revision 1.1
Added some feature
================