DEV Community

Roy
Roy

Posted on

quote in ssh bash -c

alt text

    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\""
Enter fullscreen mode Exit fullscreen mode

https://serverfault.com/q/953087/576644

Discussion (0)