1

I have a directory containing gzipped datafiles. I want to run each file using the script est_abundance.py. But first i need to unzip them. So i have this bash:

for file in /home/doy.user/scratch1/Secoutput/; do
    cd "$file"
    gunzip *kren.gz
    python analysis1.py -i /Secoutput/*kren -k gkd_output -o /bracken_output/$(basename *kren).txt
    wait
done

The problem is, the bash script keeps on unzipping all of the datafiles, it does not continue to the next command after unzipping one file. Can you help me correct this? I just want every command to be done for every file.

Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115
Dale Pin
  • 61
  • 1
  • 9

1 Answers1

0

Use, notice that you should use $file variable, and you can get the name of the file after unzipping by stripping the .gz part using ${file%.gz}:

for file in /home/doy.user/scratch1/Secoutput/*; do
    gunzip $file
    python analysis1.py -i ${file%.gz} -k gkd_output -o /bracken_output/$(basename ${file%.gz}).txt
    wait
done
Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115