how to change the display format of a file

April 2, 2012 at 04:24:42
Specs: Windows XP
Hi all,
I want to store the file creation/modification date in "year month date" format.
As of now, the file creation dates looks as "mmm dd hh:mm".
Is it possible to display the datestamp of the UNIX file in yyyymmdd or other format..
please, let me know if this is answered.

Thanks,
Raj


See More: how to change the display format of a file

Report •

#1
April 2, 2012 at 04:46:17
If you mean in directory listings, use the --time-style switch to ls. For example:

ls -l --time-style=+%Y%m%d

Read the man pages for "ls" and "date" for more details.

Internally the dates are always stored as a number of seconds.


Report •

#2
April 3, 2012 at 07:24:02
Hi,
While listing the files in a directory,
the old file is diplaying as:
-rw-r--r-- 1 user group size Jul 26 2011 file1.dat
whereas, the new files is diplaying as:
-rw-r--r-- 2 user group size Apr 2 hh:mm file2.dat

Actually, the old files (i.e. 6 monsths ago) have "mm dd yyyy" format. and the new files have "mmm dd hh:mm" format.
So, is that to possilbe to change the datestamp of the UNIX file in yyyymmdd or other formats while displaying.

Please, let me know your suggestion.

Thanks


Report •

#3
April 3, 2012 at 09:10:22
The -time-style option to ls is a GNU (i.e. Linux) extension. Legacy unix systems (HP-UX, Solaris, AIX) do not support that.

There is no way that I know of to change legacy ls output other than to write a shell script to change it. This link shows how I solved the problem:

http://www.computing.net/answers/un...


Report •

Related Solutions

#4
April 3, 2012 at 23:00:02
Thanks for your help :)

Report •

Ask Question