How would I mix patterns and numeric ranges in sed (or any similar tool – awk for example)? What I want to do is match certain lines in a file, and delete the next n lines before proceeding, and I want to do that as part of a pipeline.
Unix – sed or awk: delete n lines following a pattern
awksedunix
Related Topic
- Bash – How to do a recursive find/replace of a string with awk or sed
- How to delete from a text file, all lines that contain a specific string
- Linux – How to use sed to remove the last n lines of a file
- Linux – Delete empty lines using sed
- Unix – How to select lines between two marker patterns which may occur multiple times with awk/sed
- Perl – How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)
Best Answer
I'll have a go at this.
To delete 5 lines after a pattern (including the line with the pattern):
To delete 5 lines after a pattern (excluding the line with the pattern):