Operating System - Linux
1748014 Members
4771 Online
108757 Solutions
New Discussion юеВ

Re: Parsing a single file into multiple files

 
SOLVED
Go to solution
James R. Ferguson
Acclaimed Contributor

Re: Parsing a single file into multiple files

Hi John:

The thread I would like you to look at dates from September:

https://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1063457

Happy New Year!

Regards!

...JRF...
Sandman!
Honored Contributor

Re: Parsing a single file into multiple files

On closer inspection I agree with JRF that the awk construct I posted earlier will not do the job owing to the variable format of field three in the input file. Besides I used a small portion of the sample input you had provided to test my script. So I used the entire input file provided, built another script that provides the desired output. And thank you for those words JRF, coming from the master himself :)

Give the awk script below a try:

# awk -F" +" '{if($0!~"^ " && $0!~"^$")p=z[split($2,z,":")-1];print $0>>"patch."p}' file

~cheers
john guardian
Super Advisor

Re: Parsing a single file into multiple files

Thanks guys. All input appreciated. I'm off and running now. See you all in the New Year!