How do I sudo if in Bash? How do I sudo if in Bash? shell shell

How do I sudo if in Bash?


if sudo test -d "/home/otheruser/svn"; then


You need to run it under a subshell. Example:

if sudo bash -c '[[ -d "/home/otheruser/svn" ]]'then  echo "SVN exists"else  echo "SVN does not exist"fi