edwardb001
Technical User
Hi,
how can i return the value of a variable used within a loop to the main program?
from the below example, the value of $loop_counter is different once the program exits the while loop (within the while loop, $loop_counter is the value of the number of times records a read, but once exiting the loop, $loop_counter is 1)
thanks.
#! /bin/sh
loop_counter=1; export loop_counter
while read FX_Cash_Flow_Report_details
do
cp $FX_Cash_Flow_Report_details ${new_report_name}_${loop_counter}_rpt
loop_counter=`expr $loop_counter + 1`; export loop_counter
echo $loop_counter
done < $INFINITY_REPORTS_LOG_DIR/${new_report_name}.fnd
echo $loop_counter
how can i return the value of a variable used within a loop to the main program?
from the below example, the value of $loop_counter is different once the program exits the while loop (within the while loop, $loop_counter is the value of the number of times records a read, but once exiting the loop, $loop_counter is 1)
thanks.
#! /bin/sh
loop_counter=1; export loop_counter
while read FX_Cash_Flow_Report_details
do
cp $FX_Cash_Flow_Report_details ${new_report_name}_${loop_counter}_rpt
loop_counter=`expr $loop_counter + 1`; export loop_counter
echo $loop_counter
done < $INFINITY_REPORTS_LOG_DIR/${new_report_name}.fnd
echo $loop_counter