0

I have a problem with implementing

if

elif ( && ) ||

else

fi

This is the particular code:

#!/bin/bash

EOSDIR=/eos/user/o/user/muonDIS/2-5-SBT
OutputFile53=PositionData_1.txt
OutputFile52=out_1.root
OutputFile51=TotData_1.txt

if test -e "$EOSDIR"/5/"$OutputFile51"; then
    echo "File exists and is unbroken. Nothing to do..."
        exit 0
elif [[ test -e "$EOSDIR"/5/"$OutputFile52" && [ $(stat -c %s "$EOSDIR"/5/"$OutputFile52") -lt 504 ] ]] || [[ test -e "$EOSDIR"/5/"$OutputFile53" ]]; then
    echo "Files are either broken or absent. New files will be generated"

else
  echo "Go away"
fi

It says

./t.sh: line 11: conditional binary operator expected ./t.sh: line 11:

syntax error near -e' ./t.sh: line 11: elif [[ test -e

"$EOSDIR"/5/"$OutputFile52" && [ $(stat -c %s

"$EOSDIR"/5/"$OutputFile52") -lt 504 ] ]] || pp test -e

"$EOSDIR"/5/"$OutputFile53" ]]; then'

3
  • 3
    Please paste your script at shellcheck.net and try to implement the recommendations made there. Commented May 23, 2022 at 21:51
  • 4
    Use either [[ or test, not both. Commented May 23, 2022 at 21:57
  • 1
    If you aren't going to write an answer as an answer, go ahead and delete the question. Answers do not belong in questions; if you want to add your own you should use the "Add an Answer" button, and write it in such a way as to be useful to other people having the same problem. Commented May 23, 2022 at 22:19

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.