Issue
I want to loop through all the files in the directory and check their perms (if user wants) but for some reason I'm getting this error:
./perms.sh: line 12: syntax error near unexpected token `;;'
./perms.sh: line 12: ` r) if [ -r $i ] then echo 'True' else echo 'False' fi ;;'
here is my code:
#!/bin/bash
for i in *
do
echo "Do you want to check rights for $i (y/n)"
read marzi
if [ $marzi = 'y' ]
then
echo 'which commands to check? '
read check
case $check in
r) if [ -r $i ] then echo 'True' else echo 'False' fi ;;
w) if [ -w $i ] then echo 'True' else echo 'False' fi ;;
x) if [ -x $i ] then echo 'True' else echo 'False' fi ;;
*) echo 'unrecognized!' ;;
esac
else
echo "skipped $i"
fi
done
does this have something to do with apostrophe?
Solution
maybe correct inline if format should be
if [ -r $i ]; then echo 'True'; else echo 'False'; fi
make sure to make change for r and w and x
Answered By - stuffy Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.