Computing.Net > Forums > Unix > Shell Script

Shell Script

Reply to Message Icon

Original Message
Name: sam_varg007
Date: December 29, 2003 at 11:23:48 Pacific
Subject: Shell Script
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



Report Offensive Message For Removal


Response Number 1
Name: nails
Date: December 29, 2003 at 12:06:35 Pacific
Subject: Shell Script
Reply: (edit)

Hi:

Use the Unix date command:

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

or

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

Regards,

Nails


Report Offensive Follow Up For Removal

Response Number 2
Name: James Boothe
Date: December 29, 2003 at 12:09:27 Pacific
Subject: Shell Script
Reply: (edit)

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.


Report Offensive Follow Up For Removal

Response Number 3
Name: James Boothe
Date: December 30, 2003 at 06:14:30 Pacific
Subject: Shell Script
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 4
Name: nails
Date: December 30, 2003 at 07:30:00 Pacific
Subject: Shell Script
Reply: (edit)

James:

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

Happy New Year!


Nails


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Shell Script

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software