Binutils stat非法选项-c [英] Binutils stat illegal option -c

查看:157
本文介绍了Binutils stat非法选项-c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在脚本中使用stat两次,一次是查找文件文件权限,一次是查找文件大小.

I use stat two times in my script once to find the file files permissions and once to find the size of the file.

 `stat -c %A "$directory/$file"`
 `stat -c %s "$directory/$file"`

我正在使用OSX 10.7,目录和文件是我当前所在目录和文件的变量.

I am using OSX 10.7 and directory and file are variable of the current directory I am in and the file.

推荐答案

Darwin stat使用-f参数而不是-c,因为它是GNU扩展.

Darwin stat uses an -f argument, rather than -c, as it is a GNU extension.

您应该从 homebrew 下载gnu binutils. .macports.org/"rel =" nofollow noreferrer> macports 或来自 fink ,和然后使用gstat代替stat.

You should download the gnu binutils, either from homebrew, from macports or from fink, and then use gstat instead of stat.

如果您不想安装gnu binutils并希望坚持使用标准BSD工具,则:

If you don't want to install gnu binutils and prefer to stick with the standard BSD tools, then:

stat -f%p t.c

将返回模式(八进制)和

will return the modes (in octal) and

stat -f%z t.c

将返回大小.

这篇关于Binutils stat非法选项-c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆