0

I am trying to submit various pbs files to the HPC using this script. However, I am getting an error in my for loop that I am not able to fix.

I am trying to count the number of files that meet the criteria for submission and then loop through and submit them all.

for i in {1..3}; do

      cd "${i}"
      
      files=(*_R$r_*.pbs)
      fnum=${#files[@]} 
      
    for k in {1.."$fnum"}; do 
        
        subm=`echo ${files[$k]}`
        qsub "$subm"
    done;
    
      cd ..
done;

The error i receive is {1..9}: syntax error: operand expected (error token is "{1..3}") fnum is counting the number of files correctly but then the loop doesnt run

  • 1
    Brace expansion happens before parameter expansion and thus you can't specify a range using a variable. – Shawn Jul 25 '21 at 09:46
  • Running your scripts through https://shellcheck.net will help with discovering issues. – Shawn Jul 25 '21 at 09:48

0 Answers0