Here is a general way to do this:
$ cat file 1 titi 2 tata 3 toto 4 tata 5 foo 6 tata 7 bar $ $ awk '/tat/{ if (++f == 1) next} 1' file 1 titi 3 toto 4 tata 5 foo 6 tata 7 bar $ $ awk '/tat/{ if (++f == 2) next} 1' file 1 titi 2 tata 3 toto 5 foo 6 tata 7 bar $ $ awk '/tat/{ if (++f ~ /^(1|2)$/) next} 1' file 1 titi 3 toto 5 foo 6 tata 7 bar
Please note that using the above approach, you can skip any occurrences of RE that you like (1st, 2nd, 1st and 2nd, independently), and you will specify only one RE (unlike necessary duplicate it for some alternative solutions).
Clear, simple, obvious, easy to repair, extensible, etc.
source share