简体   繁体   中英

use variable from while do loop bash

I have the while loop below that is using the variable pov. I need each line set to a variable that can be called in a connection string, but cant figure out how to create a loop to feed each line separately.

wanting if [ ! -z $pov] then .../shell to execute using $pov... fi if [ ! -z $pov] then .../shell to execute using $pov... fi for each line in seq_fy.txt

What I am working with:

cat seq_fy.txt | while read pov; do
echo "pov$((n++))=$pov"
###wanting "if [ ! -z $pov] then <execute> fi" for each line in seq_fy.txt
done

$ ./while_loop_only
pov0=
pov1=SPT_SEQ_010,FY15
pov2=SPT_SEQ_010,FY16
pov3=SPT_SEQ_020,FY15
pov4=SPT_SEQ_020,FY16
pov5=SPT_SEQ_030,FY15
pov6=SPT_SEQ_030,FY16
pov7=SPT_SEQ_040,FY15
pov8=SPT_SEQ_040,FY16
pov9=SPT_SEQ_050,FY15
pov10=SPT_SEQ_050,FY16

Looks like I have been way over-analyzing this.... basically I don't need anything with POV or exporting variables at all, just simply put the command inside the while loop and fed in $line, and seems to work as expected

cat fiename.txt | while read line; do
$owsdirectory"/hpm_ws_client.sh" processCalcScriptOptions "$appName" "$line" "$layers" "$stages" "" "$stages" "$stages" FALSE > "$appLogFolder""/""$line""_ProcessID.log"
done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM