rm scenery.db #Insert "insert into filedata_temp values(" " at the beginning of each line cat "$1" | sed 's/^/insert into filedata_temp values("/' > "$1"_temp1.txt #Remove the ":" cat "$1"_temp1.txt | sed 's/://g' > "$1"_temp2.txt #Replace the " " and the " " blanks between the fields with "," cat "$1"_temp2.txt | sed 's/ /","/g' | sed 's/ /","/g' > "$1"_temp3.txt #Replace the EOL with "); cat "$1"_temp3.txt | sed 's/.$/");/' > "$1"_temp4.txt #Eventually use... # cat "$1"_temp3.txt | sed 's/$/");/' > "$1"_temp4.txt #...if the file does not have a MSDOS EOL #Eliminate the first line which contains the header echo "create table filedata_temp (filename varchar2(100), left varchar2(30), right varchar2(30), top varchar2(30), bottom varchar2(30));" > "$1"_ready.txt echo "begin transaction;" >> "$1"_ready.txt tail -n +2 "$1"_temp4.txt >> "$1"_ready.txt echo "end transaction;" >> "$1"_ready.txt echo "create table filedata(namehoriz number, namevert number, left varchar2(30), right varchar2(30), top varchar2(30), bottom varchar2(30));" >> "$1"_ready.txt echo "insert into filedata select substr(filename, 1, 6), substr(filename, 8, 6), left, right, top, bottom from filedata_temp;" >> "$1"_ready.txt rm -v "$1"_temp1.txt rm -v "$1"_temp2.txt rm -v "$1"_temp3.txt rm -v "$1"_temp4.txt sqlite3 -init "$1"_ready.txt scenery.db #rm -v "$1"_ready.txt