get file modification date in number format (yyyy mm dd hh mm ss)

How do i get the file modification date in number format (yyyy mm dd hh mm ss)

i used

ls -l pathname

but month is still in text "Aug" and year and time is not allways shown. time is show if it is in this year. and year is shown if it is before this year.

what do i need to get modification date info in number format (yyyy mm dd hh mm ss)

this is the info i found on the ls command.
Linux and UNIX ls command help
ls [-a] [-A] [-b] [-c] [-C] [-d] [-f] [-F] [-g] [-i] [-l] [-L] [-m] [-o] [-p] [-q] [-r] [-R] [-s] [-t] [-u] [-x] [pathnames]
-l Shows you huge amounts of information (permissions, owners, size, and when last modified.)
pathnames File or directory to list.

What OS are you using?

If you have the stat command, you can get the modification date with:

stat -c %y file

If your find command supports the printf action, something like:

find . -name "file" -printf "%TD %TT\n"

Hi Franklin,

It's OS X.

The stat command does do the job nicely:

$ stat -lt "%Y.%m.%d %H:%M" file1  # format as required
-rw-r--r-- 1 scott staff 405 2010.08.28 14:04 file1

How did you find it out? :slight_smile:

It was posted in the OS X forum :wink:

O, my.....:eek: still sleeping, need another cup of coffee :smiley:

$ stat -lt "%Y.%m.%d %H:%M" file1 # format as required
-rw-r--r-- 1 scott staff 405 2010.08.28 14:04 file1

thats what i need. thanks.

is it possible to only get the de date and time info not "-rw-r--r-- 1 scott staff 405 "

$ stat -f"%Sm %SN" -t "%Y.%m.%d %H:%M" file1
2010.08.27 21:42 file1
1 Like