[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to name an archive



On a local filesystem, having one long line can work well.  But in email, it
can be problematic.  For example, your quoted message (as received by my
mailserver) has a linebreak after $TSTAMP" , so a user not familiar with shell
scripts might think that their script should be:

    #!/bin/bash
    TSTAMP=$(date +%Y-%m-%d-%H%M)
    /usr/local/bin/tarsnap -c -v -f "pictures and music $TSTAMP"
    ~/backup/

Admittedly, this gives the warning:

$ tarsnap-backup.sh 
tarsnap: no files or directories specified
/home/td/.bin/tarsnap-backup.sh: 10: /home/td/.bin/tarsnap-backup.sh:
/home/td/backup/: Permission denied

so nobody will think that their backup was successful... but on the balance, I
think that using \ reduces more problems than they add.


Using back ticks was absolutely a mistake, though, and I'm glad that we've
fixed that on the website!

Cheers,
- Graham

On Wed, Jun 01, 2016 at 05:00:41PM -0500, Tim Stoodt wrote:
> Hi,
>       I agree. Those back ticks are rough to read. I also was never
> much for using \ to go to extend to another line.
> Just string it onto one line. My two cents.
> 
> #!/bin/bash
> 
> TSTAMP=$(date +%Y-%m-%d-%H%M)
> 
> /usr/local/bin/tarsnap -c -v -f "pictures and music $TSTAMP"
> /users/sa/music /users/sa/movies /users/sa/pictures
> 
> # End of the script
> 
> 
> On 06/01/2016 04:20 PM, Garance AE Drosehn wrote:
> >Note that you do want the backward-quotes for the 'date' part,
> >but not for the full string.  But it would also be easier to read
> >if you used the more modern alternative for the backward-quotes.
> >
> >So try:
> >    ...  -f "pictures-and-music $(date +%D-%M-%Y_%H-%M)"
> >
> >Also, my guess is that you don't really want that first two
> >date-values to be "%D-%M".  That gives you the full date followed
> >by the minute.  I expect you want "%d-%m', which would give you
> >day-of-month followed by the month-number.
> >
> >Personally, I prefer to order time values by "bigness", so I'd
> >use the order of year, month, day, hour, minute.  To get that,
> >you'd go with:
> >
> >    ...  -f "pictures-and-music $(date +%Y-%m%d_%H%M)"
> >
> >Note that you need the string-delimiters to be double-quotes,
> >not single-quotes.  If you used single-quotes, then the shell
> >will not expand the $(date...) part.
> >
> >I hope this helps.
> >
> >	-- garance alistair drosehn
> >
> >
> >>On Wed, 1 Jun 2016 13:44:54 -0700
> >>Sarah Alawami <marrie12@gmail.com> wrote:
> >>>Here is the script.
> >>>
> >>>#!/bin/sh
> >>>
> >>>/usr/local/bin/tarsnap -c \
> >>>-v -f `pictures and music `date +%D-%M-%Y_%H-%M`` \
> >>>/users/sa/music /users/sa/movies /users/sa/pictures
> >>># End of the script...
> >>>
> >>>Do I have the right idea here? It looks like it half way works but it
> >>>is not naming the archive what I want to name it. Once I get this set
> >>>up I'll never need to worry again, I hope lol!
> >>>
> >>>Everyone be blessed and have a happy wednesday.
>