Binutils stat illegal option -c

I use stat twice in my script once to find file file permissions and once to find file size.

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

I am using OSX 10.7, and the directory and file are the variables of the current directory in which I am located and the file.

+5
source share
1 answer

Naked Darwin 'stat does not allow the -c option, as it is a GNU extension. Instead, you download gnu binutils, either from a homebrew, or from a port, or from fink, and then use gstat instead of stat.

If you do not want to install gnu binutils, then stick with the standard BSD tools, this way:

stat -f "%p" t.c

will give modes (in octal) and

stat -f "%z" t.c

will give a size.

+10
source

All Articles