Tag Archives: bash: syntax error near unexpected token `(‘

[Solved] Error: bash: syntax error near unexpected token ` (‘

You need to delete a zip package in the server and execute the operation deletion prompt: – bash: syntax error near unexpected token ` (‘

Failed to delete normally

Reason: after Linux 5.0, parentheses cannot be used, and translation is required

There are two methods of Translation:

  1. adding escape characters\
  2. 2.just add “” in parentheses

I add double quotation marks directly, and then delete it successfully.

How to solve bash: syntax error near unexpected token ‘(‘ in Linux

Recently, in the development process, I want to delete a jar package on the server, but the name of the jar package is in parentheses
at the beginning, I deleted it like this:

rm -f HIBIKI_API(1).jar

But I got the following sentence:

bash: syntax error near unexpected token `(' 

Then I googled it and found that after linux5.0, you can’t use brackets. At this time, you need to translate. There are two ways of translation

1.rm -f HIBIKI_API\(1\).jar
2.rm -f "HIBIKI_API(1).jar"

In this way, the translation will be OK