mercredi 8 mai 2019

How to print out files using if not condition in bash

Say I have three files in a directory dir

touch a.ym b.ym a.job 

And I need to print all *.ym if it has no corresponding *.job file. So this what I tried,

for file in $(find ${dir} -name \*.ym);do
    sample_id=$(echo "${filebase}"| awk -F'[.]' '{print $1}')
    filenamepattern="${yml}/${sample_id}.job"
      if  [[ $sample_id != *".job" ]]; then
                echo "${file}"
      fi
done

However, the above solution is printing out both

a.ym b.ym files, where I need only b.ym file to be printed out

Aucun commentaire:

Enregistrer un commentaire