Back
While listing a directory can I view numerical Unix permissions such as 644 rather than the symbolic output
-rw-rw-r--
Use the below code:
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}'
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}'
To know about Linux join the Linux Course
Do check out the video below
31k questions
32.8k answers
501 comments
693 users