35

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?

  • 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

    – jaamarks Mar 20 '19 at 18:13

3 Answers3

34

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)
Radu Rădeanu
  • 174,437
14

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 (
Zanna
  • 72,471
Andy J
  • 1,137
  • 1
  • 13
  • 19
  • 3
    This one was my case. Also in my case even sourcing empty file didn't delete aliases created. So had to manually call unalias . Only after that sourcing file worked for me. – Arsen Sench Sep 09 '22 at 11:19
  • 1
    Similar behavior. The alias previously created doesn't go away. Either unalias it or open a new terminal for the change to show up. – Coder Mar 24 '23 at 19:13
14

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.

chaos
  • 28,256