0

in my script an if statement returns:

line 3: []: command not found

the statement:

if ["$(pidof -x $(basename $0) -o %PPID)"]; then
    echo process already running; exit;
fi

what I tried:

if [["$(pidof -x $(basename $0) -o %PPID)"]]; then
    echo process already running; exit;
fi
if [["$(pidof -x basename $0 -o %PPID)"]]; then
    echo process already running; exit;
fi
if ["$(pidof -x basename $0 -o %PPID)"]; then
    echo process already running; exit;
fi
if [[$(pidof -x basename $0 -o %PPID)]]; then
    echo process already running; exit;
fi

none seems to work.I get similar error.

line 3: [[]]: command not found

I got the code from here: https://linuxpip.org/rclone-examples/ https://forum.rclone.org/t/continuous-syncing/12377/2

I did research here: https://wiki.bash-hackers.org/syntax/ccmd/conditional_expression and looked at the man bash’s Compound Commands section but they don’t seem to help.

please help Thank you!

andy
  • 1
  • add at least one space after [ and [[ and before ] and ]]. – cas Oct 18 '21 at 05:36
  • .. and those required spaces are in the web page cited. Best reference is https://www.gnu.org/software/bash/manual/bash.html -- not Google. – Paul_Pedant Oct 18 '21 at 07:31

0 Answers0