Find the answer to your Linux question:
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 ...
  1. #1
    Just 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.

  2. #2
    Just Joined!
    Join Date
    Feb 2009
    Posts
    45
    Quote Originally Posted by jenea
    This is my script:
    Code:
    #!/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/
    […]
    The problem is that the tar command would run only in the following syntax (see date part):
    Code:
    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'
    You quote the variable. It is done thusly:
    Code:
    tar -cvz --newer "$today_day" -f /mnt/usb_backup/backup/diff/backupFull_`date +%Y%m%d`.tgz /mnt/mirror80gb/

  3. #3
    Just Joined!
    Join Date
    Mar 2009
    Posts
    5
    oh, wow..... i cannot believe i didn't try that....

    Thank you.......it works......

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...