Linux File Modification Time – Get File Modification Time in Specific Format (yyyymmddhh24miss)

datelinuxstat

I want to get the modification time of a file in a specific format.
How can I do that ?
I know about

stat -c %x find.txt

but I need this format:

yyyymmddhh24miss

I'm using ksh on Linux 2.6.18-406.el5 x86_64 if it matters.

Best Answer

You can use something like:

/bin/date +%Y%m%d%H%M%S -d "$(/usr/bin/stat -c %x find.txt)"
Related Question