BEGIN { FS="\"" } NR==1 { thepattern=$0 next } NR==2 { theoutput=$0 next } NR==3 { theweb=$0 next } { if ( index( $6, thepattern) != 0 ) { thefilename= $6 } } END { filecr= substr( thefilename, index( thefilename, "c")+1, 4) print "if ( ! -e ../cr" filecr " ) mkdir ../cr" filecr print "wget " theweb thefilename " -O ../cr" filecr "/" filecr theoutput }