5

AWK specific output filename

view full story
linux-howto

http://www.unix.com – Hi All, I'd like to create a specific output filename for AWK. The file I am processing with AWK looks like: Code: output_081012.csv* 27*TEXT*1.0*2.0*3.0 where * is my delimeter and the first line of the file is the output filename i'd like to create is there a way to assign an awk variable to the first line and then use that variable in the printf command to create the output file? for instance Code: awk -f inputfile BEGIN { FS='*' if (FNR==1) outputfile=$1 } { if {FNR==2} printf("%s,%s,%s,%s,%s\n",$1,$2,$3,$4,$5) >>outputfile } Thanks! Moderato (HowTos)