#!/sw/bin/awk -f function basename(s) { while ((p=index(s, "/")) != 0) { s = substr(s, p+1); } return s } function org(s) { while ((p=index(s, "/")) != 0) { t = substr(s, 1, p-1); s = substr(s, p+1); } return t } { base = basename($2); # base still has the .cm extension... cruise = substr(base,1,length(base)-3); # get the name of the originating agency from file name #src = org($2); print $1, cruise, $3, $4 }