Solved CLI tool better than stat?

Solved issue

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
863
Reaction score
709
Credits
5,825
Is there any CLI tool that is better and can replace stat? Stat is too limited and... incompetent, for the lack of a better word. Sometimes for different reasons I need to have the OS install date which I print with

Code:
stat -c %w /

but that prints the date in the weirdest possible format which frankly I find annoying. No matter what I try, I can't make it print the date (only dd mm yyyy and nothing else - I don't need time of install or time zone) in my locale format. That makes me think stat is... well, useless. So I'm asking you: do you know of any stat-like CLI tool but which is better at formatting its own output?
 


@rado84 , do I take it that you have already considered and rejected

tune2fs

and

dumpe2fs

or do you have need of more functionality, and if so what?

Cheers

Wizard
 
I don't understand what you really want here? Just timestamps of file system changes?

Could you do something like...

ls -l / | awk {'print $6" "$7" "$8'}
 
or do you have need of more functionality, and if so what?
I need something to display the date / was created (meaning when the OS was installed) in this format: "DD MM YYYY" (with the intervals). What stat currently shows isn't very easy to read:
2023-07-28 01:31:27.486276000 +0300

Edit: it turns out stat alone ain't enough. I had to put it inside date for it to work the way I needed:

Code:
date -d "$( stat -c '%w' / )" +'%d %b %Y'

The operating system was installed on:
28 юли 2023
The date is displayed according to the locale language, that's why it's in Cyrillic. I guess I'll replace the month with a number.
 
Last edited:
For my preference, and might suit Members from UK, Australia, New Zealand, Netherlands, France and many others, I would use

Code:
date -d "$( stat -c '%w' / )" +'%d/%m/%Y'
31/12/2022

... and US Members might like

Code:
date -d "$( stat -c '%w' / )" +'%m/%d/%Y'
12/31/2022

(taken under one of my Gecko Linux)

Cheers

Wiz
 

Members online


Top