Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
別のユーザーのホーム ディレクトリにあるディレクトリを確認する必要があります。通常は sudo を実行しますが、それによって別のプロセスがフォークされ、環境も失われます。
たとえば、私は持っています:
if [[ -d "/home/otheruser/svn" ]]; then echo "SVN exists" else echo "SVN does not exist" fi
root 権限で実行するには、テスト条件が必要です。
if sudo test -d "/home/otheruser/svn"; then
サブシェルで実行する必要があります。例:
if sudo bash -c '[[ -d "/home/otheruser/svn" ]]' then echo "SVN exists" else echo "SVN does not exist" fi