[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

need to add current date in filename

Posted on 2005-05-16
2
Medium Priority
?
728 Views
Last Modified: 2009-12-16
i have a small shell script that backs up my databases. i want to change it so it adds the dats (YYYY-MM-DD) to the beggining of the filename, here it is.

#EXPORT TABLES
/usr/local/bin/mysqldump --opt --compress -hHOST -uUSER -pPASSWORD ldww_db TABLENAME >> backups/database/TABLENAME.dat.sql    

so basically it should be
backups/database/YYYY-MM-DD-TABLENAME.dat.sql

how do it do that? thanks!
0
Comment
Question by:qwertq
2 Comments
 
LVL 6

Accepted Solution

by:
knollbert earned 300 total points
ID: 14014886
/usr/local/bin/mysqldump --opt --compress -hHOST -uUSER -pPASSWORD ldww_db TABLENAME >> backups/database/$(date +%F).dat.sql
0
 
LVL 38

Expert Comment

by:yuzh
ID: 14015450
use the following as the file name:

`date +%Y-%m-%d`.dat.sql

eg:

/usr/local/bin/mysqldump --opt --compress -hHOST -uUSER -pPASSWORD ldww_db TABLENAME >> backups/database/`date +%Y-%m-%d`.dat.sql


0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month17 days, 16 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question