Determine if a file is writable by a Bourne script user

Contributor Icon Contributed by Rex Date Icon October 20, 2003  
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

Previous recipe | Next recipe |
 
blog comments powered by Disqus