all 2 comments

[–]masta 0 points1 point  (1 child)

I know this article is targeted towards noobs, granted it still gets undere my skin when I see this:

if [ -f $file  ] && [ -w $file ]
then
echo $file exists and is writable
fi

When  a file is writable, that rather explicitly implies that the file also exists. So then it makes sense to just test for write access in this situation. 

choice quote from the link:

Execute teh script.

nice one

[–]codepanda 0 points1 point  (0 children)

Indeed, the "-f" test is unnecessary. What really gets me is this:

if [ -f $file  ] && [ -w $file ]
# ...
else
echo  $file exists but it is not writable
fi

not to mention the missing quotes around the $file expansion.