LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bash scripting using date (https://www.linuxquestions.org/questions/programming-9/bash-scripting-using-date-519769/)

pueblonative 01-16-2007 06:36 AM

Bash scripting using date
 
Here's the file so far:


Quote:

myfilename = $(date +%m%d%y) + ".tar.gz"
echo $myfilename

And here is the error:

Quote:

./backupfiles.sh: line 1: myfilename: command not found

I know I'm missing something, what is it?

druuna 01-16-2007 06:40 AM

Hi,

There are spaces between myfilename and = and $(.......), they should not be there. I.e:

myfilename="$(date +%m%d%y).tar.gz"

I also removed the + bit and changed the quotes.

Hope this helps.

pueblonative 01-16-2007 06:48 AM

Thanks, that worked.

jlliagre 01-16-2007 09:34 AM

By the way, "+%m%d%y" is broken (unsortable and ambiguous), you should use "+%Y%m%d" or "+%F" instead.


All times are GMT -5. The time now is 11:03 AM.