perl -pe 's/TABLE;(.*)\n// and $t=$1;s/COLUMN;(\w+);.*/$t.$1/' #### mkdir ../fld-lists for i in *; do perl -pe 's/TABLE;(.*)\n// and $t=$1;s/COLUMN;(\w+);.*/$t.$1/' $i >../fld-lists/$i done