awk

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

awk

kishore
Hi,

I have below sample data and need to split the records based on records having START  value ignoring second repeated START value in to separate files.

START
Unix
Linux
START
Solaris
Aix
SCO
START
kishore
windows
oracle
db2
teradata
START
abinitio
datastage
informatica
business onject
START

I got the below AWK command which is working fine. Need to know how it is working. Can you please explain .

awk -v delim=-1  -v SPLIT_COUNT=2 -v SPLITPATH="/users/" '/START/ {delim++} { file = sprintf(SPLITPATH"Final_Temp%s.txt", int(delim /SPLIT_COUNT)); print >> file; }' < filename;