Try:
bash -c '[ -d my_mystery_dirname ] && run_this_command'
EDIT . This will work if you can run bash on a remote computer ....
EDIT 2 . In bash, [ -d something ] checks to see if there is a directory named "something" by returning a success code if it exists and is a directory. Chaining commands with && only starts the second command if the first is successful. Therefore, [ -d somedir ] && command runs the command only if the directory exists.
sinelaw Jan 30 2018-11-11T00: 00Z
source share