Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-14-2006, 07:55 AM   #1
Registered: Oct 2005
Distribution: Debian@work / Ubuntu@home
Posts: 42

Rep: Reputation: 15
Shell Script.. Date format handling


I just want to check the current date and use it in the name of a database backup.
I did it that way in a shell script :

CURRENT_DATE=date '+%d%m%y-%Hh%M'

mysqldump -u[username] -p[password] --opt [database] > /go/over/there/backup/DB_backup_"$CURRENT_DATE".sql
There is a syntax problem with the date, I got the backup but the filename doesn't keep the date...
Old 02-14-2006, 08:10 AM   #2
Senior Member
Registered: Mar 2004
Location: england
Distribution: Debian, Mint, Puppy, Raspbian
Posts: 3,421

Rep: Reputation: 199Reputation: 199
 CURRENT_DATE=$(date +%d%m%y-%Hh%M)
 CURRENT_DATE=`date +%d%m%y-%Hh%M`
$( command ) works for ksh & bash
`command` works for all plus plain old 'sh'

Last edited by bigearsbilly; 02-14-2006 at 08:13 AM.
Old 02-14-2006, 08:34 AM   #3
Registered: Oct 2005
Distribution: Debian@work / Ubuntu@home
Posts: 42

Original Poster
Rep: Reputation: 15
thx for this one!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
shell script to remove old files based on date WindozBytes Linux - General 12 06-04-2012 01:21 AM
Date format Mik LQ Suggestions & Feedback 8 12-05-2004 10:14 AM
Shell Script for Gzipping with date output Junior41180 Programming 1 10-16-2004 06:39 AM
Shell script ip address format check. rooch84 Linux - Software 6 08-18-2004 09:14 AM
Bulk image format conversions with a shell script? infidel Linux - Software 4 11-16-2003 07:20 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:37 PM.

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