Techno World Inc - The Best Technical Encyclopedia Online!

THE TECHNO CLUB [ TECHNOWORLDINC.COM ] => Shell Script => Topic started by: Mark David on March 16, 2007, 01:36:21 PM



Title: Determine if a file is writable by a Bourne script user
Post by: Mark David on March 16, 2007, 01:36:21 PM
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.

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