BASH and wildcard expansion

Roberto Ragusa mail at robertoragusa.it
Tue Aug 20 13:33:15 UTC 2013


On 08/19/2013 08:56 PM, Mark Haney wrote:
> I've hit a problem I can't quite figure out which a bash script I'm writing.  I'm trying to copy backup files in the format 2013-August-18--1123.zip to an NFS share.  I want to have the script copy the file with just the date.  In bash I've setup vars that get the current date:
> 
> # Date variables
> log_year=`date "+%Y"`
> log_month=`date "+%B"`
> log_day=`date "+%d"`

Partially offtopic hint:

avoid multiple date invocations, you can get wrong results at the midnight
of the last day of the month
(and it's much worse when doing hours,minutes,seconds).

Just do:

log_ymd=`date +%Y-%B-%d`


-- 
   Roberto Ragusa    mail at robertoragusa.it


More information about the users mailing list