LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-30-2008, 05:11 PM   #1
namit
Member
 
Registered: Aug 2005
Distribution: Debian
Posts: 355

Rep: Reputation: 30
backup scripting problem


Hello all,

Just been messing about with backing up my home drives but wondering how do i get around this problem.

Quote:
da=`date +%Y-%m-%d`
mo=`date +%Y-%m`

backyback:~# echo $mo
2008-10
backyback:~# echo $da
2008-10-30
but how do I get (2008-09 and 2008-09-30) or (2008-08 and 2008-09-30) ?

Thanks
 
Old 10-30-2008, 05:19 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can specify a date different from the current date using the -d option. The argument will be a date string in a standard format with or without an additional amount of time, relative to the specified date. For example, the following are all valid date specifications:
Code:
date -d yesterday
date -d 20080711
date -d "20080711 4 days"
date -d "2 days ago"
date -d "20080711 2 days ago"
date -d "1 month ago"
date -d tomorrow
and so on... Look at info date (sections "Options for date" and "Date input formats") for more details.
 
Old 10-30-2008, 05:56 PM   #3
namit
Member
 
Registered: Aug 2005
Distribution: Debian
Posts: 355

Original Poster
Rep: Reputation: 30
Thats perfect now i do not have to move the old backup files every month when my server fills up.
 
Old 10-30-2008, 06:51 PM   #4
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by namit View Post
Thats perfect now i do not have to move the old backup files every month when my server fills up.
Also the "date" command has this functionality...

Code:
date +%F
Now you can set your variables to this command...

Code:
stamp=$(date +%F)
-C
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in scripting john83reuben Programming 8 02-27-2008 10:24 PM
Bash scripting: backup/restore or copy of Evolution's settings akines Programming 1 07-02-2007 02:26 PM
scripting problem bhert Linux - Newbie 4 10-10-2006 12:24 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
Shell scripting problem ecsjohn Programming 7 02-03-2006 06:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:24 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