#!/usr/bin/gawk -f # /* vim: set filetype=gawk : */ -*- awk -*- BEGIN{ FS = ","; Fname="test"; Out=""; } { Del = 9; for(i=Del;i<=NF;i++) { $i = ""; } gsub(/ +/,","); gsub(/\t+/,","); gsub(/,,+/,","); } /^,/{ $0 = substr($0,2,length($0)-1); } /,[^.]/{ $0 = substr($0,1,length($0)-1); } { Out= Out $0 "\n"; } END{ print Out>Fname; }