LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-23-2005, 06:34 PM   #1
matsko
Member
 
Registered: Dec 2005
Posts: 51

Rep: Reputation: Disabled
Linux Bash Date Characters


I want to have a system where when I backup my mysql database. The script would save the filename according to its date.

so

mysql_backup_full-2005-23-12.sql
mysql_backup_full-2005-24-12.sql
mysql_backup_full-2005-25-12.sql

...and so on

but you see how the date of the file is different (because it is backed up on a certain day)

how would I make the name so that when the backup_mysql file is executed it would save the filename as today's date..


thanks
 
Old 12-24-2005, 05:23 AM   #2
linmix
Senior Member
 
Registered: Jun 2004
Location: Spain
Distribution: FC5
Posts: 1,993
Blog Entries: 1

Rep: Reputation: 46
set a date variable in your script
date='date -y -d' (check out the flags you need, these are just a random example!!)

then write the outgoing filename like this:

mysql_backup_full-"$date".sql
 
Old 12-24-2005, 06:00 AM   #3
DarkElf109
Member
 
Registered: Dec 2005
Location: Phoenix, AZ
Distribution: Ubuntu, Debian, Gentoo
Posts: 43

Rep: Reputation: 15
date=`date +%Y-%d-%m`

Put that somewhere in your script, and, as linmix said, use $date wherever you want the date, in your specified format, to show up.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash and filenames with special characters CoolAJ86 Programming 2 03-09-2005 02:50 PM
bash printing extended ASCII characters nutthick Programming 6 02-04-2005 02:15 PM
(bash) change many characters into one six6 Programming 9 12-31-2004 06:16 AM
Set name of tar file as date using bash otisthegbs Linux - Software 5 12-18-2003 03:34 PM
Date in a BASH script... soulsniper Linux - Software 7 11-22-2003 06:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration