I have a template script with some analysis and the only thing that I need to change in it is a case.
#!/bin/bash
CASE=XXX
... the rest of the script where I use $CASE
I created a list of all my cases, that I saved into file: list.txt.
So my list.txt file may contain cases as XXX, YYY, ZZZ.
Now I would run a loop over list.txt content and fill my template_script.sh with a case from the list.txt and then saved the file with a new name - script_CASE.sh
for case in `cat ./list.txt`;
do
# open template_script.sh
# use somehow the line from template_script.sh (maybe substitute CASE=$case)
# save template_script with a new name script_$case
done
while read -r c; do sed "s/^CASE=.*/CASE=$c/" template_script.sh > "script_{c).sh"; done < list.txtexport CASE=xxxand that this variables are available in your script? Rewriting code is in most cases a silly idea. If you really need templates, you should consider an appropriate tool likem4.while read -r c; do sed "s/^CASE=.*/CASE=$c/" template_script.sh > "script_${c}.sh"; done < list.txt