FreeBSD find the chmod numerical value for a file or directory
I need to find out the numerical value of a file on a FreeBSD system. For example, get 644 instead of -rw-r--r-- for the /etc/resolv.conf file. Is there is a way to get this value in my bash shell script?
You need to use the stat command to see information about the file.
The basic syntax is: stat file stat [options] file
To see info about /etc/resolv.conf, enter: $ stat /etc/resolv.conf Sample outputs:
The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.