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.
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.