0
ssh user@host "mv \"/some/path/fi\'le.txt\" /some/new/path"

It doesn't matter what I do, or what combination of quotes I use on the file, it gives the following:

bash: -c: line 0: unexpected EOF while looking for matching `'' bash: -c: line 1: syntax error: unexpected end of file

marked as duplicate by Gilles shell Jan 25 '16 at 23:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • did you try dropping the `\` before the single quote ? – MelBurslan Jan 25 '16 at 19:57
  • @MelBurslan Yes, that does not work. – user153241 Jan 25 '16 at 20:04
  • @Gilles can't make this an answer because it was marked as a duplicate but i don't know the reason why, i will quote the bash documentation p.7 The backslash retains its special meaning only when followed by one of the following characters: ‘$’, ‘‘’, ‘"’, ‘\’, or newline. Within double quotes, backslashes that are followed by one of these characters are removed. Backslashes preceding characters without a special meaning are left unmodified. , the solution is , save the path into a variable and then mv the expansion $variable – user3566929 Jan 25 '16 at 23:32
  • 1
    @user3566929 No, that wouldn't work. It couldn't help anyway since you're just transfering the quoting difficulty to where you assign the variable. There are two levels of expansion here, one by the local shell and one by the remote shell. Read the answers at unix.stackexchange.com/questions/4770/… – Gilles Jan 25 '16 at 23:42