Let's say I want to delete some lines after the pattern while skipping some lines in-between, and then delete the line with the pattern itself. I can do this using the following two commands:
sed -i '/PATTERN/{n;n;n;n;n;n;N;N;N;N;d}' file # match pattern, skip 5 lines, then delete 5 consecutive lines sed -i /PATTERN/d file # delete line with pattern But I want to do this in a single command. The problem here is obvious as the pattern change affects both expressions so the change must be specified in a single expression. Is there a way to achieve this?
UPDATE:
Example input:
... ifeq ($(ose),) dh_installdocs \ $(archdir)/UserManual*.pdf $(archdir)/VirtualBox*.chm \ $(addprefix $(archdir)/, LICENSE) rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.chm \ LICENSE) else dh_installdocs \ $(archdir)/UserManual*.pdf rm $(addprefix $(archdir)/,UserManual*.pdf) endif ... Example output:
... dh_installdocs \ $(archdir)/UserManual*.pdf $(archdir)/VirtualBox*.chm \ $(addprefix $(archdir)/, LICENSE) rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.chm \ LICENSE) ... UPDATE 2:
The example file can be obtained here: http://download.virtualbox.org/virtualbox/5.0.4/VirtualBox-5.0.4.tar.bz2 (debian/rules)
sedand a single command? Can you give an example input and output for testing? But first thought would - if you're doing keyed on the same pattern, doesn't that mean you're deleting then skipping?x;after{. This partially works as it deletes everything from the line with the matching pattern while leaving a blank line. Is there a way to remove the whole line?