directory = `dirname /path1/path2/path3/file.txt` if [ -w "$directory" ] then echo $? else echo $? fi