Command 'ls' output numerical chmod permissions

Linux 15 ก.ค. 2018

it almost can …


ls -l | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) *2^(8-i));if(k)printf("%0o ",k);print}'

and

stat -c "%a %n" *

Also, you can use any filename or directory name instead of * to get a specific result.

On Mac, you can use


stat -f '%A %N' *

ref: https://stackoverflow.com/questions/1795976/can-the-unix-list-command-ls-output-numerical-chmod-permissions

แท็ก

Onyx

Just a middle-aged programmer, Can do many things but not the most.