I am writing a bash script to automatically import a tab-delimited file into an MySQL database. The problem is that I want to add a date column to the file before I import it into the database. The date is included in the filename.
For example, assume a file named patientinfo_20070217.txt. Initially, the tab-delimited file looks like this:
Bob Billy 3423
Hunt George 1232
Adams John 3456
Before importing this file into the MySQL database, I want to change the file to look like this:
Bob Billy 2007-02-17 3423
Hunt George 2007-02-17 1232
Adams John 2007-02-17 3456
Hunt George 2007-02-17 1232
Notice that the date is the same date that is stated in the filename. Does anyone know how to do this?
For example, assume a file named patientinfo_20070217.txt. Initially, the tab-delimited file looks like this:
Bob Billy 3423
Hunt George 1232
Adams John 3456
Before importing this file into the MySQL database, I want to change the file to look like this:
Bob Billy 2007-02-17 3423
Hunt George 2007-02-17 1232
Adams John 2007-02-17 3456
Hunt George 2007-02-17 1232
Notice that the date is the same date that is stated in the filename. Does anyone know how to do this?