Is it possible to format the time output of stat? I am using
stat -c '%n %A %z' $filename
in a bash script, but its time format is not what I want. Is it possible to change this format in the command, or would I have to manually do it later?
An example output follows:
/lib drwxr-xr-x 2010-11-15 04:02:38.000000000 -0800
You can simply strip of the decimal portion like this:
Edit:
Here's another way to truncate the decimal portion:
This depends on the date being 19 characters long:
2010-11-15 04:02:38
You could try something like:
Which gives you only the date. You can format the date using date's formatting options (see man date), for example:
This doesn't give you the name and permissions but you may be able to do that like: