PDA

View Full Version : [SOLVED] Copy Files with the Command Line - Error Using Parentheses



famulusmercury
October 8th, 2012, 03:32 AM
How do you copy files with () in the name using the command line?

eg. = cp my (file) name.txt /home/user/Documents

result = -sh: syntax error: "(" unexpected

I know you have to put "\" before a space in the file name, but what do you do about parentheses in the file name?

Vaphell
October 8th, 2012, 03:39 AM
you can try using \ to escape () too, but it would be easier to put the name in quotes "" or '' (now you wont have to manage spaces either)

besides try autocompletion - type first few chars, press tab and the name should be expanded to its full form, with all the necessary escaping done for you, as long as there is no ambiguosity.

papibe
October 8th, 2012, 03:40 AM
what do you do about parentheses in the file name?
Hi famulusmercury.

You can do the same, and escape them:

mv myfile\(2012\).txt /tmp
or you can use quotes:

mv "myfile(2012).txt" /tmp
Let us know how it goes.
Regards.

famulusmercury
October 8th, 2012, 03:49 AM
That got it. Thanks!