LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 03: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, 03:59 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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, 04: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, 05:40 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,421

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


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


All times are GMT -5. The time now is 10:51 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration