Get the chmod numerical value for a file

You can get the value directly using a stat output format, e.g. BSD/OS X:

stat -f "%OLp" <file>

or in Linux

stat --format '%a' <file>

and in busybox

 stat -c '%a' <file>

use stat YOUR_FILE unless write script that calculate :

rwx rwx rwx ==> ( r = 4 ) if set + ( w = 2) if set + (x = 1) if set , for example:
You have :
-rw-wxrw- => (4+2+0)(0+2+1)(4+2+) = 0636 
First argument before 9 permissions is one of :
- = regular file
d =  directory
b = block device
c = character device
s = socket
p = pipe
f = fifo

By the way , I use stat command on Linux box, not freebsd, because it investigate HFS probably work with UFS.


Some additional information on stat:

$ stat -c %a file.txt

777  

$ stat -c %A file.txt

-rwxrwxrwx