1
mysql --host *HOST* --p   --user *USERNAME*  -e "query"  > file.lst
pause

My code looks as above. Is there a way to rename the file.lst and add sysdate at the end and make it like file19072016.lst? Assume that the date needs to be changed everyday and the file is run everyday.

2 Answers 2

3

Do it using this command:

mysqldump -hlocalhost -uroot -p DBNAME > file$(date +"%d%m%Y").lst

Sample output:

file19072016.slt

Thanks to @terdon.
See edit history.

0
1

You can create the desired file-name like so:

FILE="file`date +"%d%m%Y"`.lst"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .