Determine if a file is writable by a Bourne script user

Contributor Icon Contributed by Rex  
Tag Icon Tagged: Bourne shell scripting  

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

 

No Comments -


No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment -