Difference between revisions of "File permission demonstration script"
From assela Pathirana
Jump to navigationJump to search
Line 1: | Line 1: | ||
<pre> | <pre> | ||
#!/bin/bash | #!/bin/bash | ||
fmt="% | fmt="%7s%7s%7s%15s%15s\n" | ||
printf $fmt umask file dirs files dirs | printf $fmt umask file dirs files dirs | ||
while read line | while read line | ||
Line 24: | Line 24: | ||
will produce the following output: | will produce the following output: | ||
<pre> | <pre> | ||
umask file dirs files dirs | |||
022 759 648 drwxr-xr-x -rw-r--r-- | |||
027 754 643 drwxr-x--- -rw-r----- | |||
002 775 664 drwxrwxr-x -rw-rw-r-- | |||
006 771 660 drwxrwx--x -rw-rw---- | |||
007 770 659 drwxrwx--- -rw-rw---- | |||
077 714 603 drwx------ -rw------- | |||
</pre> | </pre> |
Revision as of 04:10, 24 March 2006
#!/bin/bash fmt="%7s%7s%7s%15s%15s\n" printf $fmt umask file dirs files dirs while read line do set -- $line umask $1 touch tempfile mkdir tempdir fval=`ls -l tempfile|awk '{print $1}'` dval=`ls -dl tempdir|awk '{print $1}'` printf $fmt $1 "$(( 777 - $1 ))" "$(( 666 - $1 ))" $dval $fval rm -rf temp* done << EOF 022 027 002 006 007 077 EOF
will produce the following output:
umask file dirs files dirs 022 759 648 drwxr-xr-x -rw-r--r-- 027 754 643 drwxr-x--- -rw-r----- 002 775 664 drwxrwxr-x -rw-rw-r-- 006 771 660 drwxrwx--x -rw-rw---- 007 770 659 drwxrwx--- -rw-rw---- 077 714 603 drwx------ -rw-------