split file having similar tags
Hi
I have a file which holds records like Code:
<record> Thanks in advance Alex |
Something like this might work ... :) if the records are separated by a blank line.
Code:
awk 'BEGIN{RS=ORS="\n\n";FS=OFS="\n";count=1}{print $0 > FILENAME"."count; if(NR%3==0){count++}}' file That sample will chop 3 records and place them into a file each lot |
See if this helps
Code:
awk 'BEGIN{RS="</record>";count=1;i=1} {{print $0"</record>">>"file"i;count++;if(count>2){i++;count=1}}} END{system("rm file"i" ")}' input Each new file is named, file1,file2..etc. |
All times are GMT -5. The time now is 05:30 AM. |