Reputation: 165
I know that
sed '/match/ d' file
deletes all lines with matches, and
sed '1,3 s/match//g' file
deletes all matches in the first 3 lines.
But how do I delete all lines with matches in first 3 lines?
If possible, give a solution with only one sed call (no piping).
Upvotes: 1
Views: 1242
Reputation: 41456
If you like to test awk
, it would be:
awk '/match/ && NR<=3 {next} 1' file
Upvotes: 0
Reputation: 123528
You could combine the two:
sed '1,3{/match/d;}' file
This would delete lines containing match
in the specified address range, i.e. in lines 1-3 in the example above.
Upvotes: 3