select distinct account_no from adj order by account_no;
This query returns account number daily.Sometimes it may return 90 rows sometime it may return 1 row only and someday it may return 0 rows
I am storing the output of this query in [b]sql_output.txt.
I am passing the account number to another shell script
bip.sh
how can i do this in a loop
bip.sh 01 account_number_1;
bip.sh 02 account_number_2; ---this bip.sh is second instance of bip.sh
i mean i want to take 2 different account numbers at a time and pass it to
bip.sh
Let me rephrase.
Currently,I am storing account numbers in my sql_output.txt.
I am passing one account number one at a time to bip.sh(it runs in the background and genrate a number which i need to fetch).
how can i run
sh bip.sh 01 $i ---i has my first account number
sh bip.sh 01 $ --- what variable should i use here so it gets the second account number
while read acc
do
bip.sh $acc
done < sql_output.txt
This will loop for every record in your file. Be careful if you need to exclude things such as the column headings and numbers of row returned or blank lines.
If you have more than one column in the file and (for instance) the account number is in column 2 and you don't care about columns 1, 2 or three and from 5 onward, you could:-
while read col1 col2 col3 acc rest
do
bip.sh $acc
done < sql_output.txt
You could run bip.sh 01 $acc if the 01 is a required parameter or even bip.sh 01 $acc & to run it in the background, but be careful if your file may have more than just a few records. There are limits to how many processes you should have running at the same time.