LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 05-28-2006, 04:21 PM   #1
stan0934
LQ Newbie
 
Registered: Jun 2005
Posts: 2

Rep: Reputation: 0
Question 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
 
Old 05-28-2006, 04:37 PM   #2
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,244

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
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
 
Old 05-28-2006, 05:16 PM   #3
stan0934
LQ Newbie
 
Registered: Jun 2005
Posts: 2

Original Poster
Rep: Reputation: 0
Many thanks. I somehow new it would be something easy that I missed.
 
Old 05-29-2006, 03:24 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Why introduce a variable, though? :}

mkdir `date +%Y%m%d`


Cheers,
Tink
 
Old 05-29-2006, 05:48 AM   #5
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
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.
 
Old 05-29-2006, 02:29 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 05:29 AM
Scripting help. welby Linux - General 1 07-22-2005 09:32 PM
Need Help on Scripting wongedan Linux - Newbie 2 08-23-2004 09:11 PM
Need some scripting help Askari Programming 1 11-26-2003 11:25 AM
scripting help wedgeworth Linux - Software 10 09-25-2003 02:57 PM


All times are GMT -5. The time now is 01:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration