I have output that I need to export to a file. Then I need to call this file to run the script in it. Another condition would be to run the last query or instruction after 15mins. See code below:#SORT RESULT IN DESCENDING ORDER. #FORMAT SYNTAX FOR BACKUP DELETIONsort -r ${TEMPRESULT2} | sed -e s/^/DELETE BACKUP /g | sed -e s/$/ NOWARNING/goutput:DELETE BACKUP (backupid) NOWARNINGDELETE BACKUP (backupid) NOWARNING[pause then run after 15mins]DELETE BACKUP (finalbackupid) NOWARNINGthe final backup id can only run once all other backupids are donehope someone could help. 
shell scripting export file
shell script
You have two different sequence of command to be executed at two different times. The most logical solution would therefore be to put these command in two different files:TEMPRESULT3=$(sort -r ${TEMPRESULT2} | sed -e s/^/DELETE BACKUP /g | sed -e s/$/ NOWARNING/g)# Put all lines except the last one in a first script:echo $TEMPRESULT3 | head -n -1 >path/to/first-script# Put the last line in a second script:echo $TEMPRESULT3 | tail -n 1 >path/to/second-scriptAs far as I know negative line number is an extension of GNU head, if it is not available you must calculate the number of lines before executing it (total=$(echo $TEMPRESULT3 | wc -l); all_but_least=$(expr $total - 1), then $all_but_least cna be passed as parameter to the first head command instead of -1).After that, all you have to do is call these script the way you want. For instance, if I take the mysql syntax proposed by Benjamin B. it would be:mysql < path/to/first-script# 800 s. = 15 m.sleep 800mysql < path/to/second-script