BEGIN { char_cnt=32; line_cnt=0; print "#!/bin/bash\ndeclare -A a" } # echo bash shebang + declaring associative array for string keys NR==1 {height=$2; start=$6; print "height=" $2} # interpreting flf first line variables NR-start-1>0 && char_cnt<123 { # for every line with characters definitions: line=$0; gsub("@","",line); # replace all "@" with blank gsub("\$"," ",line); # replace all dollar signs with blank space gsub("'","'\"'\"'",line); # replace every occurance of single quote, with escape printf "a[\"%i,%i\"]='%s';", char_cnt, line_cnt, substr(line,2) # print array formated characters line_cnt++; } char_cnt<123 && match($0, /@@$/) { char_cnt++; line_cnt=0; print "" }