wget or curl throws -bash: syntax error near unexpected token `('
Asked Answered
E

4

12

I am trying to download a file which has symbol "(" in it;s URL. I tried using wget and curl. Bash is not allowing it to be processed and throws "-bash: syntax error near unexpected token `('".

Any idea how to resolve it?

Eckblad answered 12/12, 2017 at 14:4 Comment(2)
Have you tried escaping the brace with a backslash?Fattish
Thank you. Escape character solved the problemEckblad
G
11

You should escape the character by adding a "\" before it. Like \( or \)

Geaghan answered 12/12, 2017 at 14:9 Comment(0)
D
3

Add single quotes ' or double quotes " around the URL.

Dominion answered 19/3, 2021 at 1:28 Comment(0)
C
1

I hope someone found this useful.

In my case, I want to curl this file name data (1).rar

then it should be write like this in the terminal

http://example.com/data%20\(1\).rar
Consonance answered 26/11, 2018 at 4:41 Comment(0)
A
1

I encountered the same problem and solved that issue just by adding double quotes to the command what I am passing. for eg:

git checkout "<branch_name>"

Anastomose answered 8/6, 2022 at 5:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.