awk loops and deleting lines
Hi all,
I just found this forum by searching for some awk help and was wondering if any of you guys could aid me in a question I have. I have a set of text files that are set up in the following way: Quote:
What I need to do is delete any track for which nit <= 4. I was thinking that the easiest way to do this would be to write a loop that reads nit for each line starting with track and then either skip or delete nit+3 lines (to account for the blank lines in the files separating each track and the original track line itself) depending on the value of nit. I'm a complete novice at awk. My main programming experience is with C++/C# but unfortunately I am confined to a linux box at the moment. Is this a good way to go about this task? Should I be looking into perl or python? I have no idea if they would be better suited to this task. I also dont have any clue on how I would go about deleting an entire line so even if someone could clear that up for me it would be much appreciated. :) Thanks in advance for any help! |
Try this
Code:
/Track/{ split($0,array) |
Quote:
Quote:
awk: Code:
awk 'BEGIN{RS="Track"} |
Thanks, Ghostdog! I didn't know you can use \1 in gensub. Also the RS="Track" is cool! :)
|
Quote:
|
Quote:
Edit: Found it. Just in the gensub paragraph: Quote:
|
All times are GMT -5. The time now is 06:41 PM. |