file date format

ls -l doesn't return the date of a file in a numerical format

Is there an other command to retrieve the date of an existing file in one of the following formats YYYYMMDD or MMDDYYY ?

as such with ls there is no format commands,
you need to format them.

-rw-rw-r-- 1 xos xos 0 Apr 28 12:54 test.txt

There are 2 problems with the date information returned by the ls -l command :
1) the month is not indicated numerically 01 .. 12
2) the year is only displayed if it is older than 6 months

These two factors complicate reformating the output of the line above into 20060428

You need to stat the file yourself by the namesake syscall.
Either write a small C wrapper program or you could write a Perl wrapper which is more effortless

e.g.

$ perl -MPOSIX=strftime -le 'print strftime("%Y%m%d", localtime((stat shift)[9]))' /etc/passwd
20060414
$ ls -l /etc/passwd
-rw-r--r--  1 root root 2224 Apr 14 18:25 /etc/passwd

Hello,

Try passing "--full-time/--time-style" to ls command:

Here is a little example:

Try also with "stat" command:

Read the differences between times in UNIX systems:

http://www.brandonhutchinson.com/ctime\_atime_mtime.html

Regards,

--
Santi Saez