Extract comma separated value in unix

Hello All

Can anyone please guide me how to solve the issue

In the below code I am getting concat of two value in result variable with comma separated

 
 
result=`sqlplus -s / <<EOF
set pages 0 feed off;
set feedback off;
spool abc.txt
select rcrd_cnt||','||to_char(data_acq_cyc_ts,'dd.mm.yyyy') from rptg.r_sb_stg_data_fl_acq_cyc_cntl where srce_id = 1 and data_acq_cyc_cntl_id =$cntl_id and 
srce_fl_id = $p ;
spool off;
exit; 
EOF;

How to extract these two value in two different variable

$ result=val1,val2
$ OLDIFS=$IFS
$ IFS=","
$ set -- $result 
$ echo $1
val1
$ echo $2
val2
$ IFS=$OLDIFS
$ 
1 Like

Thanks Anchal .can you please send the command which can be used inside the script

That can be used inside the script!!

Another way :

$ result=val1,val2
$ v1=${result%%,*}
$ v2=${result##$v1,}
$ echo $v1
val1
$ echo $v2
val2
$

Jean-Pierre.

1 Like