Several methods of obtaining a digital file permissions

1, an idea: the letters LL command to obtain permission, then converted to a digital output:

ll test.sh |cut -c1-10|tr "rwx-" "4210"|awk -F "" '{print $1+$2+$3$4+$5+$6$7+$8+$9}'

               Get letters permission to convert digital output digital rights

2, the idea 2: stat commands directly with the output of digital rights, and command fetch sed, reference to using (after), attention escaped

stat test.sh|sed -nr 's#^.*\(0(.*)\/-r.*$#\1#gp'

 

3, the idea 3: stat awk command sets the output delimiter

stat test.sh|awk -F "[0/]" 'NR==4 {print $2}'

 

Guess you like

Origin www.cnblogs.com/zhutao-niuniu2014/p/11307926.html