I have defined each line of a text file as a variable %POV. There can be between 1 and 50 lines in the txt (so $POV01 to $POV50), and I need to run a command on all that exist. I currently have it functioning properly in a long script, where I am exporting each value, then doing an IF NOT NULL THEN statement on each of them individually.
Is there a way to build a loop to check each value, and IF n NOT NULL then, ELIF n+1....? I currently have the following I am looking to compress:
./<input_txt>
. ./<output.txt>
set | grep {"^POV"}
export pov01="\"$POV01\""
export pov02="\"$POV02\""
export pov03="\"$POV03\""
export pov04="\"$POV04\""
.... (until $pov50)
if [ ! -z $pov01 ];
then
export step=${pov01//\"/}
export step03_01=$step
export pov=${pov01//\"/}
.... (using $pov as variable in connection string)
fi
### POV #02
if [ ! -z $pov02 ];
then
export step=${pov02//\"/}
export step03_02=$step
export pov=${pov02//\"/}
....(using $pov as variable in connection string)
fi
.....
I was thinking a for loop i.e. for (pov=1, pov <=50, pov++) do, but not sure if its possible.
Aucun commentaire:
Enregistrer un commentaire