Reputation: 4297
When trying to run this 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
Notice that when execute it directly in the server it works
Thanks for any advice
Upvotes: 1
Views: 7752
Reputation: 23871
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:
'a'\''b'
becomes a'b
'a'"$x"'b'
becomes a${x}b
Upvotes: 4