Computing.Net > Forums > Unix > Shell Script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Shell Script

Reply to Message Icon

Name: sam_varg007
Date: December 29, 2003 at 11:23:48 Pacific
OS: Sun OS 5.9
CPU/Ram: 1500MHZ 523
Comment:

I am a beginner to shell script. How can I create a directory using the system date in shell script. Could anyone please send me the code?
Thanks




Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: December 29, 2003 at 12:06:35 Pacific
Reply:

Hi:

Use the Unix date command:

mkdir "mydir"$(date +"%m%d%y") # Korn

or

mkdir "mydir"`date +"%m%d%y"` # Bourne

Regards,

Nails


0

Response Number 2
Name: James Boothe
Date: December 29, 2003 at 12:09:27 Pacific
Reply:

You can embed a date command within a mkdir command:

mkdir mydir_`date +%m-%d-%Y`

Or korn shell can do it this way:

mkdir mydir_$(date +%m-%d-%Y)

You can change the formatting options of the date command to whatever you want.


0

Response Number 3
Name: James Boothe
Date: December 30, 2003 at 06:14:30 Pacific
Reply:

Sorry Nails, your reply was not there when I went to post. At least we were consistent.


0

Response Number 4
Name: nails
Date: December 30, 2003 at 07:30:00 Pacific
Reply:

James:

What's that old saying? "Great minds think alike".

Happy New Year!


Nails


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Why this command to unzip... Free BSD device namings



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Shell Script

Shell Scripting www.computing.net/answers/unix/shell-scripting/8475.html

Variables in Shell SCripting www.computing.net/answers/unix/variables-in-shell-scripting/6020.html

shell script to uninstall java www.computing.net/answers/unix/shell-script-to-uninstall-java-/5976.html