Passing 2+ parameters to one command

I have a script that uses more than one parameter. It looks like this:

for i in `cat /tmp/listofpolicies`;
do
for x in $(cat /tmp/lst |sed 's/^/\/usr\/openv\/netbackup\/db\/class\//g');
do /usr/openv/netbackup/bin/admincmd/bpplinclude $i -delete -f $x;done;done

The problem is that the file /tmp/listofpolicies contains:

CORP-GOLD-NETAPP_CH1-NDMP
CORP-GOLD-NETAPP_CH10-NDMP
CORP-GOLD-NETAPP_CH11-NDMP
CORP-GOLD-NETAPP_CH12-NDMP
CORP-GOLD-NETAPP_CH2-NDMP
CORP-GOLD-NETAPP_CH3-NDMP
CORP-GOLD-NETAPP_CH4-NDMP

and the /tmp/lst contains:

CORP-GOLD-NETAPP_CH1-NDMP/includes
CORP-GOLD-NETAPP_CH10-NDMP/includes
CORP-GOLD-NETAPP_CH11-NDMP/includes
CORP-GOLD-NETAPP_CH12-NDMP/includes
CORP-GOLD-NETAPP_CH2-NDMP/includes
CORP-GOLD-NETAPP_CH3-NDMP/includes
CORP-GOLD-NETAPP_CH4-NDMP/includes

Then when I try to run it I get the proper output from the /tmp/lst but if you notice the value on the /tmp/listofpolicies remains CH1-NDMP when I want it to cycle through the list:

for x in '$(cat /tmp/lst |sed '\''s/^/\/usr\/openv\/netbackup\/db\/class\//g'\'')'
+ /usr/openv/netbackup/bin/admincmd/bpplinclude CORP-GOLD-NETAPP_CH1-NDMP -delete -f /usr/openv/netbackup/db/class/CORP-GOLD-NETAPP_CH1-NDMP/includes
file open failed
+ for x in '$(cat /tmp/lst |sed '\''s/^/\/usr\/openv\/netbackup\/db\/class\//g'\'')'
+ /usr/openv/netbackup/bin/admincmd/bpplinclude CORP-GOLD-NETAPP_CH1-NDMP -delete -f /usr/openv/netbackup/db/class/CORP-GOLD-NETAPP_CHI10-NDMP/includes
+ for x in '$(cat /tmp/lst |sed '\''s/^/\/usr\/openv\/netbackup\/db\/class\//g'\'')'
+ /usr/openv/netbackup/bin/admincmd/bpplinclude CORP-GOLD-NETAPP_CH1-NDMP -delete -f /usr/openv/netbackup/db/class/CORP-GOLD-NETAPP_CH11-NDMP/includes
+ for x in '$(cat /tmp/lst |sed '\''s/^/\/usr\/openv\/netbackup\/db\/class\//g'\'')'
+ /usr/openv/netbackup/bin/admincmd/bpplinclude CORP-GOLD-NETAPP_CH1-NDMP -delete -f /usr/openv/netbackup/db/class/CORP-GOLD-NETAPP_CH12-NDMP/includes
+ for x in '$(cat /tmp/lst |sed '\''s/^/\/usr\/openv\/netbackup\/db\/class\//g'\'')'
+ /usr/openv/netbackup/bin/admincmd/bpplinclude CORP-GOLD-NETAPP_CH1-NDMP -delete -f /usr/openv/netbackup/db/class/CORP-GOLD-NETAPP_CH2-NDMP/includes
+ for x in '$(cat /tmp/lst |sed '\''s/^/\/usr\/openv\/netbackup\/db\/class\//g'\'')'
+ /usr/openv/netbackup/bin/admincmd/bpplinclude CORP-GOLD-NETAPP_CH1-NDMP -delete -f /usr/openv/netbackup/db/class/CORP-GOLD-NETAPP_CH3-NDMP/includes

Can someone tell me how I should enable this command to cycle through both lists instead of the $i list (/tmp/listofpolicies) always being the same value, CH1?

Any help would be greatly appreciated.

How about using paste?

paste /tmp/listofpolicies /tmp/lst | while read i x
do
   ...
done
1 Like

Try:

netbckbase=/usr/openv/netbackup
while read i && read x<&3
do
  "$netbckbase/bin/admincmd/bpplinclude" "$i" -delete -f "$netbckbase/db/class$x"
done < /tmp/listofpolicies 3</tmp/lst
1 Like

Yoda:

I never new of the paste command! This is simple and wonderful. The script completed without error! Amazing! Thanks! I will study that man page.
Didn't look at Scrutinizer's post yet, but am sure it is useful too!