27

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 Mar 20 '19 at 18:13
29

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 '21 at 8:07
10

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.

0

Mine had nothing to do with un-escaped brackets and everything to do with a bash function defined twice.

In one file:

foo() {
    # Do something
}

In another file:

foo() {
    # Do something else
}

And both of these functions were sourced by my ~.bashrc, giving me the unhelpful error message:

syntax error near unexpected token (

2
  • That is surprising. Are you sure it was two functions, and not, say, an alias and a function?
    – muru
    Nov 29 '21 at 2:17
  • Yes indeed. My apologies. It was an alias an a function called the same thing, defined to do the exact same thing!
    – Andy J
    Nov 30 '21 at 0:57

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.