Skip to content

Commit

Permalink
Adding Perms script. Solving iiitl#6
Browse files Browse the repository at this point in the history
  • Loading branch information
aryamagarwal committed Mar 15, 2024
1 parent 96850b2 commit 1abecaa
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions scripts/perms
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,37 @@
# $ perms weather ../README.md
# 775 weather
# 664 ../README.md
func ()
{
for arg in "${@}"
do
op=$(ls -l $arg)
sum=0
result=""
for (( i=1; i <= 9; i++ ))
do
if [ $(($i%3)) -eq 0 ]
then
result="${result}${sum}"
sum=0
fi
ch=${op:$i:1}
if [ $ch == 'r' ]
then
sum=$(($sum+4))
fi
if [ $ch == 'w' ]
then
sum=$(($sum+2))
fi
if [ $ch == 'x' ]
then
sum=$(($sum+1))
fi
done
echo "${result} ${arg}"
done
}

func "${@}"

0 comments on commit 1abecaa

Please sign in to comment.