LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Need scripting help!! (https://www.linuxquestions.org/questions/programming-9/need-scripting-help-449391/)

stan0934 05-28-2006 03:21 PM

Need scripting help!!
 
Can someone tell me how to pass today's julian date to the mkdir function to create a julian date folder. I have seen several posts showing something like the following:

DATE="date '+%j'" or some simple variation. All I get is a folder named date or +%j. Am I missing something?

Thanks,

Stan

jlinkels 05-28-2006 03:37 PM

I assume DATE is the name of the new directory you want to create, hence

Code:

mkdir $DATE
(better use lower case for variables)

Code:

DATE=`date +%j`
mkdir $DATE

Note the backquotes, not ordinary single quotes.

jlinkels

stan0934 05-28-2006 04:16 PM

Many thanks. I somehow new it would be something easy that I missed.

Tinkster 05-29-2006 02:24 AM

Why introduce a variable, though? :}

mkdir `date +%Y%m%d`


Cheers,
Tink

spirit receiver 05-29-2006 04:48 AM

Quote:

Originally Posted by Tinkster
Why introduce a variable, though?

Because that directory might be referenced more than once in that script, but repeatedly using the "date" command might give different results.;)

Tinkster 05-29-2006 01:29 PM

Quote:

Originally Posted by spirit receiver
Because that directory might be referenced more than once in that script, but repeatedly using the "date" command might give different results.;)

Fair comment if his script was run over midnight. :}

Cheers,
Tink


All times are GMT -5. The time now is 07:04 AM.