I have the following shell script and want to change the filename db_backup.sql to be change so the current date is prepended to it e.g. yyyy-mm-dd-db_backup.sql
#!/bin/sh
mysqldump ... /_sql/db_backup.sql
gzip -f _sql/db_backup.sql
Simple question, hopefully quick and simple answer!
You can use the
datecommand to do what you want:If you’re using a shell that doesn’t support
$(), you may need to use backticks instead: