unixcommand-linepermissions

Can the Unix list command 'ls' output numerical chmod permissions?


Is it possible when listing a directory to view numerical Unix permissions such as 644, rather than the symbolic output -rw-rw-r-- ?

Thanks.


Solution

  • 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}'