I have a script that takes many hours to finish. I would like to add the current date and time to an echo command that prints to the screen every time a step completes.
So my command creates and inserts about 20 databases. some databases take several hours to insert so I would like to print the time each step finishes to the screen so you can know where in the process the restore is. Here is what I have so far.
#!/bin/sh for DB_File in *.sql ; do mysqladmin create ${DB_File%%-*} echo ${DB_File%%-*} has been created. date +%x_%X mysql ${DB_File%%-*} < $DB_File echo $DB_File inserted into database. date +%x_%X done
$(date +%x_%X)to substitute the command output on the echo line.date. No need forecho $(date)it is pointless. And=%x_%Xis not the same as+%x_%X. =)