LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-02-2011, 08:14 AM   #1
suresh_rtp
LQ Newbie
 
Registered: Feb 2009
Posts: 3

Rep: Reputation: 0
sometime mkdir command in linux creating directory without time stamp


Hi,

i am using linux command "mkdir" for creating directories in c++.
some times mkdir command creating directory without time stamp.
is there any option to create directory with time stamp always.

Thanks & Regards,
suresh
 
Old 08-02-2011, 08:31 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,528
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
AFAIK a directory always has a timestamp. Do you mean the timestamp is zero? What are you using to display the timestamp? What does the output look like?
 
Old 08-02-2011, 09:03 AM   #3
suresh_rtp
LQ Newbie
 
Registered: Feb 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Hi catkin,

i have created TEMP directory using the following command

mkdir TEMP

output of ls -ltr TEMP

drwxr-xr-x 4 root root 4096 Aug 2 2011 TEMP

ls -ltr output will have only month date year no time(hours:minute:sec).

Thanks & Regards,
suresh
 
Old 08-02-2011, 09:14 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,528
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
ls -ltr TEMP should show you the contents of TEMP, not the directory itself.

Do you have ls aliased? what is the output of type ls ?

You can check the detailed information of TEMP, including timestamps using stat TEMP
 
Old 08-02-2011, 10:11 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
For ls to list the directory itself, not the contents, use:

Code:
ls -d /path/to/directory
But stat is a better tool for this job.
 
Old 08-02-2011, 08:27 PM   #6
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,226

Rep: Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022
There's setting somewhere in Unix such that recent dates are shown as

Mon daynum hh:mm

& anything older than 'X' is shown as

Mon daynum YYYY

I think the usual default cutoff setting (ie 'X') is something like 6 or 9 mths. Has to be less than 12 mths so you can tell the diff between 2 Aug 2011 and 2 Aug 2010 etc.
 
Old 08-03-2011, 01:08 AM   #7
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
You have the timestamp, else you would not have the correct date. You're talking about the time

The format can be influenced with the --times-style option

chrism01's example is achieved with the following
Code:
wim@webserver:~$ ls -l --time-style="+%T press <enter> here
%F" /etc/rc.d
total 324
drwxr-xr-x 2 root root  4096 04:46:18 init.d/
lrwxrwxrwx 1 root root     4 2011-05-29 rc.0 -> rc.6*
-rwxr-xr-x 1 root root  1282 03:12:55 rc.4*
-rwxr-xr-x 1 root root  7358 06:27:42 rc.6*
-rwxr-xr-x 1 root root  2322 23:29:36 rc.K*
-rwxr-xr-x 1 root root  9388 03:32:47 rc.M*
-rwxr-xr-x 1 root root 13645 03:50:59 rc.S*
-rwxr-xr-x 1 root root   466 10:20:01 rc.acpid*
-rwxr-xr-x 1 root root  1614 02:04:04 rc.alsa*
-rw-r--r-- 1 root root  1032 05:47:46 rc.atalk
-rw-r--r-- 1 root root  4370 07:02:01 rc.bind
-rw-r--r-- 1 root root  3438 08:04:13 rc.bluetooth
-rw-r--r-- 1 root root   831 08:04:13 rc.bluetooth.conf
-rw-r--r-- 1 root root  4548 23:28:19 rc.cups
-rw-r--r-- 1 root root   512 00:29:55 rc.dnsmasq
-rwxr-xr-x 1 root root   119 06:19:13 rc.font.new*
-rwxr-xr-x 1 root root  1148 2011-05-29 rc.gpm*
-rwxr-xr-x 1 root root   906 02:48:50 rc.hald*
-rw-r--r-- 1 root root  4777 07:14:12 rc.hplip
-rwxr-xr-x 1 root root   703 01:12:22 rc.httpd*
-rwxr-xr-x 1 root root  9237 04:04:10 rc.inet1*
-rw-r--r-- 1 root root  3578 2011-05-31 rc.inet1.conf
-rwxr-xr-x 1 root root  4477 04:44:44 rc.inet2*
-rwxr-xr-x 1 root root   497 05:27:32 rc.inetd*
-rw-r--r-- 1 root root  1924 01:10:07 rc.ip_forward
-rwxr-xr-x 1 root root   467 2011-05-31 rc.local*
-rwxr-xr-x 1 root root  1560 04:42:53 rc.messagebus*
lrwxrwxrwx 1 root root    23 2011-05-29 rc.modules -> rc.modules-2.6.21.5-smp*
-rwxr-xr-x 1 root root 28472 22:20:52 rc.modules-2.6.21.5*
-rwxr-xr-x 1 root root 28472 21:56:21 rc.modules-2.6.21.5-smp*
-rwxr-xr-x 1 root root  2401 2011-05-30 rc.mysqld*
-rwxr-xr-x 1 root root  2444 23:21:33 rc.nfsd*
-rw-r--r-- 1 root root   561 07:15:09 rc.ntpd
-rwxr-xr-x 1 root root  1722 23:09:31 rc.pcmcia*
-rw-r--r-- 1 root root  1402 00:53:37 rc.rpc
-rw-r--r-- 1 root root   791 05:36:53 rc.samba
-rw-r--r-- 1 root root  1169 22:24:31 rc.saslauthd
-rw-r--r-- 1 root root   967 05:54:03 rc.scanluns
-rw-r--r-- 1 root root   687 23:09:51 rc.sendmail
-rw-r--r-- 1 root root  2895 09:33:26 rc.serial
-rw-r--r-- 1 root root   895 05:51:26 rc.snmpd
-rwxr-xr-x 1 root root  1477 19:36:19 rc.sshd*
-rwxr-xr-x 1 root root   981 01:10:52 rc.syslog*
-rwxr-xr-x 1 root root  1740 22:48:40 rc.sysvinit*
-rwxr-xr-x 1 root root  4195 02:35:27 rc.udev*
-rwxr-xr-x 1 root root 11974 07:44:58 rc.wireless*
-rw------- 1 root root  7320 07:44:58 rc.wireless.conf
-rwxr-xr-x 1 root root  2323 01:56:01 rc.yp*
drwxr-xr-x 2 root root  4096 04:46:18 rc0.d/
drwxr-xr-x 2 root root  4096 04:46:18 rc1.d/
drwxr-xr-x 2 root root  4096 04:46:18 rc2.d/
drwxr-xr-x 2 root root  4096 04:46:18 rc3.d/
drwxr-xr-x 2 root root  4096 04:46:18 rc4.d/
drwxr-xr-x 2 root root  4096 04:46:18 rc5.d/
drwxr-xr-x 2 root root  4096 04:46:18 rc6.d/
wim@webserver:~$
Check if you have an LS_OPTIONS in your environment or if you have (as said earlier) an alias.


Question:
Are you talking about different machines with different behavior? Or one machine that behaves as shown above. Or one machine that behaves inconsistently (e.g. after mkdir tmp1 you don't get the time and after mkdir tmp2 you do get the time)?


PS The behavior you probably want is long-iso; the format you showed is "+%F"

Last edited by Wim Sturkenboom; 08-03-2011 at 01:13 AM.
 
  


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
Trying to make a directory with mkdir using the date command. Altheastronut Linux - General 5 06-09-2009 12:14 PM
mkdir : cannot create directory : no such file or directory patcheezy Linux - Newbie 6 05-13-2009 11:26 AM
How to Get directory time stamp in c++ craigorymaas Programming 11 04-17-2009 12:23 AM
Time stamp Kalyani1 Linux - Software 0 11-07-2005 02:58 PM
Time stamp in Samba is 11 hours behind time stamp in Linux Linh Linux - General 3 09-04-2003 12:44 PM


All times are GMT -5. The time now is 06:57 AM.

Main Menu
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