Shell: Empty shell script opening issue

Viewed 25

I have been working on mainly the 2 jobs:

1.Creating a total of 170 input files

  • All of them named as "STEP0.sh"
  • All of them contain their unique directory and unique file number (000 ~ 169)
  1. Copying each file right after being created and modified into the folder with the same name as the file (without extension)
  • After copying the file into its folder, the file must be deleted to create a new file with the name of "STEP0.sh"

Here is what I have written:

source pSTEP0.sh

for file in ${NAME}_*;do
    vim STEP0.sh;
    echo 'DIR=''"'$DIR'/'${file}'"' >> STEP0.sh;
    echo 'IN=''"'${file}'.vcf"' >> STEP0.sh;
    echo 'NAME=''"'${file}'"' >> STEP0.sh;
    cp STEP0.sh ./${file};
    rm STEP0.sh;
done;
exit

The source file: pSTEP0.sh contains these information

DIR="/sc/arion/projects/Itan_lab/minju/annotations/gnomAD/split"
NAME="gnomAD"

<> The script perfectly worked so that I could get a total of 170 "STEP0.sh" files within each of 170 folders. However, after executing the shell script, several empty shell scripts remain open even though the job was completed. Thus, I had to close all those empty shell script by manually putting ':wq' several times (more than 100 times)

<> How can I close these empty shell scripts just by modifying the shell script I have written? (automatically closed after executing the bash script)

0 Answers
Related