Mar 15, 2005 #1 cardy Technical User Sep 5, 2000 33 GB If this is easier than I think I'll kick myself. I know that I can delete all lines that match a pattern with sed -e '/<pattern>/d' input > output But how do I delete the line containing the n'th occurrence of the pattern only. Thanks cardy
If this is easier than I think I'll kick myself. I know that I can delete all lines that match a pattern with sed -e '/<pattern>/d' input > output But how do I delete the line containing the n'th occurrence of the pattern only. Thanks cardy
Mar 15, 2005 #2 PHV MIS Nov 8, 2002 53,708 FR cardy, you may try awk (example for 5th pattern): awk '/pattern/{++n}{if(n==5)++n;else print}' input > output Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244 Upvote 0 Downvote
cardy, you may try awk (example for 5th pattern): awk '/pattern/{++n}{if(n==5)++n;else print}' input > output Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244