macos - 苹果电脑 : Lack of --printf for stat

标签 macos unix stat bsd

我正在尝试在 mac 上使用 stat(使用 python),但使用此命令

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

in python 给了我一个响应: stat: invalid option -- - 它告诉我 stat --printf 'name: %n\tSize: %s 中的一些标签bytes\t 类型:%F\t 时间戳:%z\n' 错误。

我该如何解决这个问题?

最佳答案

MacOS 上的 stat 不存在 --printf 选项。

您要查找的是-f(用于格式)。

所以你可以这样做:

stat -f '名称:%n\t大小:%s 字节\t 类型:%F\t 时间戳:%z\n'

关于macos - 苹果电脑 : Lack of --printf for stat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42891856/

相关文章:

macos - 如何在 Emacs 的 shell 命令中使用正确的 rbenv Ruby 版本?

python - Python 的 Mechanize 中的 BeautifulSoup 错误

c++ - Mac OSX libc++ 缺少 std::uncaught_exceptions 符号

linux - 如何在不丢失标题的情况下查看特定进程的顶级命令?

c - 用于打印给定文件路径的 C 程序错误

macos - 告诉 Homebrew 软件永远不要从源代码构建

Linux - 如何在用户登录期间向特定用户显示文本消息

r - 提取stat_smooth线拟合的方法

cocoa - 使用 FileAttributeKey.posixPermissions 与使用 stat -f %A 有什么不同?

bash - 从分隔文件中捕获特定列