32

I am trying to download flareget download manager via wget I get error

wget  http://www.flareget.com/files/flareget/debs/amd64/flareget_2.3-24_amd64(stable)_deb.tar.gz
bash: syntax error near unexpected token `('

Why is that error coming and what is the solution for that?

1
  • I received the same error while attempting to unzip a file that was password protected. The password had a parenthesis in it. I ended up having to use both double and single quotes to avoid the error. Example: mypass="'HWNevtQW9o2s)f'" unzip -P $mypass myfile
    – jesseaam
    Mar 20, 2019 at 18:13

3 Answers 3

31

You should use single quotes ' or double quotes " around the URL in this case (and in general):

wget  'http://www.flareget.com/files/flareget/debs/amd64/flareget_2.3-24_amd64(stable)_deb.tar.gz'

From now, you should use this method in general when you use a string which contain parentheses as argument in a command. That is because parentheses are used for grouping by the shell such that they are not communicated in any way to a command. So, the bash shell will give you a syntax error:

$ echo some (parentheses)
bash: syntax error near unexpected token `('
$ echo 'some (parentheses)'
some (parentheses)
1
  • Thank you ! This is work for me!
    – linjiejun
    Mar 22, 2021 at 8:07
13

It's because of the brackets. You need to escape them like this:

wget  http://www.flareget.com/files/flareget/debs/amd64/flareget_2.3-24_amd64\(stable\)_deb.tar.gz

Now it should work.

2
  • its worked but need permanent solution
    – matinict
    Dec 6, 2022 at 19:55
  • @matinict just wrap the URL in double quotes and don't bother with the backslash. That's my permanent good practice.
    – osullic
    Jan 5 at 16:32
8

Mine had nothing to do with un-escaped brackets and everything to do with an alias already being defined with the same name as the function.

Alias in one file:

alias foo="echo do something"

Function in another:

foo() {
    # Do something else
}

Both of these files were sourced by my ~/.bashrc, giving me the unhelpful error message:

syntax error near unexpected token (
1
  • 2
    This one was my case. Also in my case even sourcing empty file didn't delete aliases created. So had to manually call unalias <aliasName>. Only after that sourcing file worked for me. Sep 9, 2022 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.