Search code examples
macosunixstatbsd

Mac: Lack of --printf for stat


I'm trying to use stat on mac (with python), but using this command

stat --printf 'name: %n \tSize: %s bytes\t Type: %F\t Timestamp:%z\n' " + j

in python gives me a response: stat: illegal option -- - which tells me that some of my tags in stat --printf 'name: %n \tSize: %s bytes\t Type: %F\t Timestamp:%z\n' are wrong.

How can I fix this?


Solution

  • 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'