Results 1 to 3 of 3
This is my script:
=========================================
#!/bin/bash
today_day=$(echo `date +"%e %b %Y"`)
echo $today_day
tar -cvz --newer $today_day -f /mnt/usb_backup/backup/diff/backupFull_`date +%Y%m%d`.tgz /mnt/mirror80gb/
This is the debug:
================================================== ===============
filer:/mnt/usb_backup/backup/test# bash -x ...
- 03-08-2009 #1Just Joined!
- Join Date
- Mar 2009
- Posts
- 5
Bash question
This is my script:
=========================================
#!/bin/bash
today_day=$(echo `date +"%e %b %Y"`)
echo $today_day
tar -cvz --newer $today_day -f /mnt/usb_backup/backup/diff/backupFull_`date +%Y%m%d`.tgz /mnt/mirror80gb/
This is the debug:
================================================== ===============
filer:/mnt/usb_backup/backup/test# bash -x jenea
+++ date '+%e %b %Y'
++ echo 8 Mar 2009
+ today_day='8 Mar 2009'
+ echo 8 Mar 2009
8 Mar 2009
++ date +%Y%m%d
+ tar -cvz --newer 8 Mar 2009 -f /mnt/usb_backup/backup/diff/backupFull_20090308.tgz /mnt/mirror80gb/
tar: Failed to open '/dev/sa0': Operation not supported
filer:/mnt/usb_backup/backup/test#
The problem is that the tar command would run only in the following syntax (see date part):
================================================== ===============
tar -cvz --newer '22 Mar 2009' -f /mnt/usb_backup/backup/diff/backupFull_`date +%Y%m%d`.tgz /mnt/mirror80gb/
My question is: How can i pass the variable's content into the tar line so in the end it looks like this --- > '22 Mar 2009'
Thank you.
- 03-09-2009 #2Just Joined!
- Join Date
- Feb 2009
- Posts
- 45
You quote the variable. It is done thusly:
Originally Posted by jenea
Code:tar -cvz --newer "$today_day" -f /mnt/usb_backup/backup/diff/backupFull_`date +%Y%m%d`.tgz /mnt/mirror80gb/
- 03-09-2009 #3Just Joined!
- Join Date
- Mar 2009
- Posts
- 5
oh, wow..... i cannot believe i didn't try that....
Thank you.......it works......


Reply With Quote