Skip to content
Advertisement

[[ operator fails with error “conditional binary operator expected”

Linux bash script fails for the following line. Error message as given. I know i can simply use if [ -f file1.txt ] but curious to know what needs to be fixed to make this working.

JavaScript

conditional binary operator expected expected `)’

Advertisement

Answer

The mv command shouldn’t be inside the conditional expression, it’s a command that you want to execute depending on the result of the condition. It should be

JavaScript

Also, don’t put it inside double parentheses, that’s for arithmetic expressions, not commands.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement