0

I cannot understand, what is wrong with my code. I try to print out file items in subdirectory (in special order). But I receive error

./testDir.sh: line 23: [: : unary operator expected
cut: the delimiter must be a single character
#!/bin/bash
#PBS -N printing subdirectories job2
#PBS -j oe
#PBS -A rsu
INPATH=/home/groups/covid-19/seq_reads/MGI/V300042154
cd $INPATH
for dir in */; do
  for file in $dir/*.fq.gz; do
    for file2 in $dir.fq.gz; do
      bname1=$(basename $file1 '.fq.gz')
      sample1="$( cut -d'_'-f 1,2,3<<<"$bname1")"
      read1="$( cut -d'_' -f 4 <<<"$bname1")"
      bname2=$(basename $file2 '.fq.gz')
      sample2="$( cut -d'_'-f 1,2,3<<<"$bname2")"

      if [ "$sample1" == "$sample2"]&&["$read1" != "$read2"]&&["$read1" == 1 ]; then
        echo "$sample1""$sample2""$read1""read2"
        #Here Trimmomatic should be started
      else
        true
      fi
    done
  done
done



          
Brian61354270
  • 8,690
  • 4
  • 21
  • 43

0 Answers0