Reputation: 4653
This deletes lines matching pattern from filename, with -i
the output is written to filename
sed -i '/pattern/d' filename
delete the first 10 lines of a file
sed '1,10d'
How do I combine the 2 to find the pattern in every line after the first line and if found delete that line? This is my attempt at getting the lines I want to apply my search to(the 2nd line to the last line):
tail -n +1 mergedfile.csv | head -n -1
How do I add the sed part to it?
Upvotes: 0
Views: 128
Reputation: 58430
This might work for you (GNU sed):
sed '1b;/pattern/d' file
or:
sed '1!{/pattern/d}' file
Upvotes: 2