//Random Tip
Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow

You are viewing a random entry, refresh your browser to change.

Tip 205 is an interesting way to show file permissions in octal using sed, but this can be done much easier using the Linux stat command.

From man page of Linux stat(1) command:
%A Access rights in human readable form
%a Access rights in octal
%n File name

stat -c '%A %a %n' *

Sample output:
-rwxr-xr-x 755 netp.sh
drwxr-xr-x 755 old_dump
-rw-r--r-- 644 tdiff.sh

View Comments »


Add your comment

Comments are currently disabled
The version of stat found on some non-Linux systems might not recognize the -c option.  

On OS X Leopard, for example, the same result can be achieved using the -f option as follows:

stat -f "%Sp %OLp %N" *
Posted 2009-04-21 19:20:40

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit