I am writing an if statement to check multiple conditions, but when I try to execute the script it is breaking at the point of if statement by showing the issue below.
Code I am using is given below.
if [ "$run" -eq "1" ] -a [ [ -f /tmp/start.Lck || -f /tmp/stop.Lck ] ]
then
....
else
...
fi
The problem is that you use -a outside the brackets. The -a and -o operators belong to the test/ command and can't be used outside. Then on the right side you use the || inside the brackets but the test/ command doesn't understand || but only -o. Outside the use && instead of -a.
This works for me here:
#!/bin/bash
run=1
if [ "$run" -eq "1" ] && [ -f ~/.bashrc -o -f ~/.vimrc ]
then
echo bingo
fi