I'm trying to create multiple shell scripts from a file with variable name. I have a bash for loop that creates the necessary lines but I want a new file each time through the loop. The script I currently have puts everything into one file. The input file (test.txt) has each variable on a separate line:
a
b
c
Here is the code I currently have:
#!/bin/bash
num=0
echo $num
for x in $(<test.txt)
do
echo \#\!/bin/bash
echo \#SBATCH -N 1
echo \#SBATCH -t 6:00:00
echo \#SBATCH --job-name=${x}
echo \. \~/\.profile
echo time java -jar trimmomatic.jar PE -threads 20 ${x}_R1.fastq ${x}_R2.fastq
num=$((num+1))
done > trim_${num}.sh
echo $num
exit
This would write three loops with a,b,c variables to trim_0.sh. I want the a loop to be in trim_0.sh, the b loop to be in trim_1.sh, and the c loop to be in trim_2.sh.
forloop.)