> $ 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 <coreutils-bounces+williambader=hotmail....@gnu.org> on behalf 
of Peng Yu <pengyu...@gmail.com>
Sent: Monday, March 15, 2021 10:16 PM
To: Coreutils <coreutils@gnu.org>
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