Search code examples
awkgrepls

Creation date of a file


How do I return a date of a file? Something like this does not work and it is ugly too.

ls -l tz1.sql | awk '{print $7$6 $8}'
7Jun10:00

Solution

  • You can use stat to get the modification time, access time, or metadata change time of a file. Creation time is not recorded.

    $ stat -c '%y' t.txt
    2011-09-30 11:18:07.909118203 -0400