LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 08-30-2005, 06:26 PM   #1
Altheastronut
LQ Newbie
 
Registered: Aug 2005
Location: Santa Cruz
Distribution: Mandriva 2005 LE
Posts: 8

Rep: Reputation: 0
Trying to make a directory with mkdir using the date command.


Is it possible to create a directory using the date command? mkdir date of course does not work, I've been trying various things but I'm out of ideas, I don't know many commands so I had a limited about of ideas.
 
Old 08-30-2005, 06:38 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Try this
Code:
mkdir `date '+%m%d%y'`
 
Old 08-30-2005, 06:48 PM   #3
Altheastronut
LQ Newbie
 
Registered: Aug 2005
Location: Santa Cruz
Distribution: Mandriva 2005 LE
Posts: 8

Original Poster
Rep: Reputation: 0
Awesome, yeah it worked thanks, I was close, but you nailed it.
 
Old 08-30-2005, 06:51 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Glad to help!
 
Old 06-09-2009, 01:00 PM   #5
bshipman2k
LQ Newbie
 
Registered: Jun 2009
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by homey View Post
Try this
Code:
mkdir `date '+%m%d%y'`
Is there any way to have this make a directory with yesterdays date? I tried mkdir `date '+%m%d-1%y'` but of course that doesn't work...
 
Old 06-09-2009, 01:14 PM   #6
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Quote:
Originally Posted by bshipman2k View Post
Is there any way to have this make a directory with yesterdays date? I tried mkdir `date '+%m%d-1%y'` but of course that doesn't work...
You can use the -d option to specify a date other than the current date:
Code:
mkdir $(date -d yesterday +%Y%m%d)
you can also specify a certain day and add or subtract hours, days, months and so on, for example:
Code:
$ date -d "3 days ago"  # subtract three days from today
$ date -d "20090311 4 days"  # add 4 days to 11-Mar-2009
All this is explained in
Code:
$ info date
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
backup from date keep directory structure secretlydead Linux - General 1 09-30-2005 04:51 PM
mkdir: cannot create directory `test': Read-only file system punt Linux - General 2 04-16-2005 10:58 PM
mkdir command digitalgravy Linux - General 5 08-12-2004 02:03 PM
can I use date command with mkdir? ewto Linux - General 6 06-16-2004 09:47 AM
"mkdir: cannot create directory `foo': Read-only file system" on FAT32 maddes Linux - Hardware 1 11-26-2003 07:19 PM


All times are GMT -5. The time now is 05:07 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