Determine if a file is writable by a Bourne script user

From a Bourne shell script (sh, ksh, bash, …), it is possible to test if a file exists and is writable by the user running the script.


if [ -w testfile ]
then
echo testfile is writable!
else
echo non writable...
fi

The Conversation

Follow the reactions below and share your own thoughts.