简体   繁体   中英

Linux shell single quotes and double quotes in one command

I need your help to make this command work:

ssh -t user@localhost "cd /tmp ; PROMPT_COMMAND='echo -ne "\033]0;log\007"' ; bash"

Here is the error that I get:

bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 1: syntax error: unexpected end of file
Connection to localhost closed.
log007' ; bash: command not found

Thanks

我建议用反斜杠( \\" )转义双引号:

ssh -t user@localhost "cd /tmp ; PROMPT_COMMAND='echo -ne \"\033]0;log\007\"' ; bash"

它经过两个壳,这意味着两个字符串扩展,因此逃脱内部部分:

ssh -t user@localhost "cd /tmp ; PROMPT_COMMAND='echo -ne \"\033]0;log\007\"' ; bash"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM