$如果您不想扩展变量,则需要转义符号:
$ x=abc$ bash <<EOF> x=def> echo $x # This expands x before sending it to bash. Bash will see only "echo abc"> echo $x # This lets bash perform the expansion. Bash will see "echo $x"> EOFabcdef
因此,在您的情况下:
ssh user@host bash << EOF# run script with output...REMOTE_PID=$(cat $FILE_NAME)echo $REMOTE_PIDEOF
或者,您也可以使用带单引号的herestring:
$ x=abc$ bash <<< '> x=def> echo $x # This will not expand, because we are inside single quotes> 'def
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)