LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-06-2010, 02:53 AM   #1
thetiger2003
LQ Newbie
 
Registered: Apr 2009
Posts: 23

Rep: Reputation: 0
script to create directory with date


i need to create script to make directory with the current date
example : the directory name is " 060122010,1100" or near to that format
 
Old 12-06-2010, 02:59 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Take a look at the date command. You can customize the format by which the date is displayed and embed it in shell commands using command substitution. Example:
Code:
mkdir $(date +%Y%m%d-%H%M)_my_dir
Take in mind that the format yyyymmdd is more suitable for file names, since they will be sorted in time order when displayed by the ls command. Also take a look at the -d option of date, to retrieve a date other than today.
 
Old 12-06-2010, 03:06 AM   #3
thetiger2003
LQ Newbie
 
Registered: Apr 2009
Posts: 23

Original Poster
Rep: Reputation: 0
thnx alot and best regards
 
Old 12-06-2010, 04:40 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Don't forget to mark as SOLVED once you have a solution.
 
  


Reply



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
Bash Script - adding file modification date to end of filenames in directory themonkman Programming 2 09-01-2009 11:45 PM
Create a script to cd into my previous directory alpha883 Programming 4 05-08-2009 08:55 AM
How to create an executable script that starts execution at a specific date and time? jtag Linux - General 3 08-12-2008 08:36 PM
Bash script to read file and alter lines depending on create date ChristianHein Linux - General 13 08-04-2007 05:39 AM
how to write a script to create a directory mgam Linux - Newbie 1 10-29-2003 12:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:26 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
Open Source Consulting | Domain Registration