Binutils stat illegal option -c

会有一股神秘感。 提交于 2020-01-13 09:44:12

问题


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"`

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


回答1:


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

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

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

will return the size.



来源:https://stackoverflow.com/questions/10666570/binutils-stat-illegal-option-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!