简体   繁体   English

远程SSH:没有这样的文件或目录

[英]Remote SSH : no such file or directory

When trying to run this cmd: 尝试运行此cmd时:

ssh user@host " cp -f /path1/`cat /path2/file.txt | awk -F : '{printf $4}' `* ../ "

got this: 收到:

cat: /path2/file.txt: no such file or directory cat:/path2/file.txt:没有这样的文件或目录

Notice that when execute it directly in the server it works 请注意,直接在服务器中执行它时,它可以工作

Thanks for any advice 谢谢你的建议

Try this: 尝试这个:

ssh user@host 'cp -f /path1/$(awk -F : '\''{printf $4}'\'' /path2/file.txt)* ..'

This might be also interesting: Useless Use of Cat Award . 这可能也很有趣: 无用的猫奖

Or this: 或这个:

ssh user@host 'cp -f '\'"$path1"\''/$(awk -F : '\''{printf $4}'\'' /path2/file.txt)* ..'

Keep in mind: 记住:

  • Singe quotes do not evaluate $. 单一报价不评估$。
  • Double quotes do evaluate $. 双引号确实评估$。
  • If you want to put a single quote into a single quoted string, you have to split the string in two parts and put an escaped single quote in between. 如果要将单引号放入单引号字符串中,则必须将字符串拆分为两部分,并在其间放置转义单引号。 'a'\\''b' becomes a'b 'a'\\''b'成为a'b
  • If you need to evaluate a variable in a single quoted string, you have to split the string in two parts and put the double quoted variable in between. 如果需要在单个带引号的字符串中评估变量,则必须将字符串拆分为两部分,并将双引号变量置于其间。 'a'"$x"'b' becomes a${x}b 'a'"$x"'b'变为a${x}b

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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