I know you can determine the owner of directory by doing:ls -ld ~/foo | awk '{ print $3 }'You could then compare it to the current user by doing this:if [[ $(ls -ld ~/foo | awk '{ print $3 }') == $USER ]] # or $(id -u -n ) instead of $USERthen    echo You are the ownerelse    echo You are NOT the ownerfiBut you can have permissions to write without being the owner. How do you determine this?
Determine if the current user has write permission in a directory
shell;permissions
I suppose if [ -w ~/foo ]; then ....should do what you want.Also, stat -c %U ~/foo is a better way to obtain the owner than parsing ls output.