Background: It is a temporary measure to load some test data into a test environment (a Sybase database).
I have a bunch of files I have to import into database daily. These files are organized as such
30Aug2011/IMPORT_ME.txt 31Aug2011/IMPORT_ME.txt ... 8Sep2011/IMPORT_ME.txt 9Sep2011/IMPORT_ME.txt
After each import I need to run some special sql statement to fix up the date. This is what I did in the main script
import_file.sh 20Aug2011/IMPORT_ME.txt cat rerun_import_file.tmpl | sed -e "s/XXX/8 Aug 2011/g" > rerun_import_files.sql $ISQL -i rerun_import_files.sql ... import_file.sh 9Sep2011/IMPORT_ME.txt cat rerun_import_file.tmpl | sed -e "s/XXX/9 Sep 2011/g" > rerun_import_files.sql $ISQL -i rerun_import_files.sql
So I suppose I can make it better by:
find all directories that fit the date pattern
sort the dates correctly (very important to the setup)
parse the date and set the date according in the sql file
However my bash script-fu is not good enough to do it.