Mac: Lack of --printf for stat Mac: Lack of --printf for stat unix unix

Mac: Lack of --printf for stat


the --printf option does not exist with stat on MacOS.

What you're looking for is -f (for format).

So you can do:

stat -f 'name: %n \tSize: %s bytes\t Type: %F\t Timestamp:%z\n'


Formatting stat output on macOS is unlike Linux versions.

stat -f 'Name: %N%tType: %HT%tSize: %z%tTimestamp: %SB%n' filename

Should return output similar to:

Name: filename  Type: Regular File  Size: 27063 Timestamp: Mar 19 01:02:20 2017

See also OS X Man Pages > stat