Operating System - HP-UX
1753506 Members
5278 Online
108794 Solutions
New Discussion

Re: How to group the output of a loop

 
SOLVED
Go to solution
Fredrik.eriksson
Valued Contributor

Re: How to group the output of a loop

To get the output to 1 "group" I would recommend doing it as a function.

This way you can execute the function within a variable and then you have a grouped output.

Something like this might be the key.
#!/usr/bin/sh
function do_dragon {
e_id=$(sqlplus -s scott/tiger@DB< SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF;
select emp_id from employee;
quit
)

group=GROUP1
# Getting the sss_no for each emp_id

for i in $e_id; do
sss_nos=$(sqlplus -s scott/tiger@DB < SET PAGES 0 LINES 500 HEAD OFF;
select sss_no from employee_bank where emp_id = $i;
quit
)

echo "List of SSS no's $sss_nos"
# Run a customize program that calls the sss_nos
# SSS_move
SSS_move $sss_nos $group
sleep 2
done
}

echo "Employee ID's $e_id"

output=$(do_dragon)
echo $output

ps. haven't tested it :P so might need some tweaking ds.

Best regards
Fredrik Eriksson