Created
June 27, 2014 17:03
-
-
Save chrislovecnm/5aa6ac7a4828b5a92d03 to your computer and use it in GitHub Desktop.
get chmod numbers for a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
// get the chmod numbers for a directory | |
// http://stackoverflow.com/questions/1795976/can-the-unix-list-command-ls-output-numerical-chmod-permissions/1796009 | |
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}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Brilliant!!