LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

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


damn...

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 :

Quote:
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
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,287

Rep: Reputation: 173Reputation: 173
try:
Code:
 CURRENT_DATE=$(date +%d%m%y-%Hh%M)
or
 CURRENT_DATE=`date +%d%m%y-%Hh%M`
:edit
$( 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
C-RAF.
Member
 
Registered: Oct 2005
Distribution: Debian@work / Ubuntu@home
Posts: 42

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


Reply


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


All times are GMT -5. The time now is 09:42 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration