This example removes the fifth occurrence of a regular expression:
printf "%s " $(seq 9) | gawk '{ print gensub(/[0-9]/,"","5") }'
1 2 3 4 6 7 8 9
This example removes the sixth instance of a regular expression:
printf "%s " $(seq 9) | gawk '{ print gensub(/[0-9]/,"","6") }'
1 2 3 4 5 7 8 9
Is possible to save the above examples in one?
I tried it, but it does not work:
printf "%s " $(seq 9) | gawk '{ print gensub(/[0-9]/,"","5|6") }'
2 3 4 5 6 7 8 9
I want printed:
1 2 3 4 7 8 9
According to the documentation, the one of the ways I can think of:
And another way (with your very specific input):