> $ stat -c '%y' file.txt
> 2017-07-31 17:50:54.000000000 +0100
> Is there a way to directly print it as 20170731-1750? Thanks.

date --date="@$(stat -c '%Y' file.txt)" '+%+4Y%m%d-%H%M'

________________________________
From: coreutils <[email protected]> on behalf 
of Peng Yu <[email protected]>
Sent: Monday, March 15, 2021 10:16 PM
To: Coreutils <[email protected]>
Subject: Print modification time in compact form

Hi,

I see modification time can be printed in this format.

$ stat -c '%y' file.txt
2017-07-31 17:50:54.000000000 +0100

Is there a way to directly print it as 20170731-1750? Thanks.

--
Regards,
Peng

Reply via email to