LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   sometime mkdir command in linux creating directory without time stamp (https://www.linuxquestions.org/questions/linux-general-1/sometime-mkdir-command-in-linux-creating-directory-without-time-stamp-895086/)

suresh_rtp 08-02-2011 08:14 AM

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

catkin 08-02-2011 08:31 AM

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?

suresh_rtp 08-02-2011 09:03 AM

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

catkin 08-02-2011 09:14 AM

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

MTK358 08-02-2011 10:11 AM

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.

chrism01 08-02-2011 08:27 PM

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.

Wim Sturkenboom 08-03-2011 01:08 AM

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"


All times are GMT -5. The time now is 11:53 PM.