Sample Header Ad - 728x90

Erasing 2-lines pattern with sed/grep/whatever

2 votes
2 answers
163 views
I have a huge cvs log file which, cleaned from the useless info, reads something like Working file: unmodifiedfile1.c ================ Working file: modifiedfile1.h ---------------------------------- revision 1.3 Fixed some bug ================ Working file: unmodifiedfile2.h ================ Working file: modifiedfile2.h ---------------------------------- revision 1.1 Added some feature ================ Working file: unmodifiedfile3.h I would like to clean the lines related to unmodified files: Working file: modifiedfile1.h ---------------------------------- revision 1.3 Fixed some bug ================ Working file: modifiedfile2.h ---------------------------------- revision 1.1 Added some feature ================ The pattern to match is Working file: FILENAME ================ What i've been able to do up to now is the following: sed '/Working file:/ N ; s/\n/PLACEHOLDER/' changelog.txt | grep -v 'PLACEHOLDER===' | sed 's/PLACEHOLDER/\n/ I'm sure however there is a cleaner solution that my sed ignorance precludes me... ( also, a bonus would be being able to erase the very latest line if necessary) P.S. An output ending with: ================ Working file: unmodifiedfile3.h is also acceptable
Asked by Davide (123 rep)
Sep 8, 2016, 01:19 PM
Last activity: Sep 12, 2016, 11:35 AM