quote in ssh bash -c
Roy
Posted on September 10, 2021
cmd="find $volumePath/data -maxdepth 1 -type f -name 'GRA_*.log' -print0 | xargs -0 -n 100 rm -v"
# 双引号中bash子命令需要使用 `\"` 引用,否则会报错 "xargs argument line too long"
ssh -p $sshPort $hostIP -- "bash -c \"$cmd\""
💖 💪 🙅 🚩
Roy
Posted on September 10, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.