concatenate 2 variables in dialog using awk while in for loop
| Hi, I have a variable $accessgroups, which has a series of comma-delimited values, like: group_a,group_b The other variable $restaccessgroups has: group_f,group_g I also have another set of variables: group_a_descr=Description of group a group_b_descr=Description of group b group_f_descr=Description of group f group_g_descr=Description of group g I now want a dialog with group_a and the value of $group_a_descr Code: dialog --separate-output --output-separator "," --checklist blah 20 80 10 `echo $accessgroups | awk -F, '{ for (i = 1; i < NF; ++i ) print $i " " ${i}_descr " on"}'` `echo $restaccessgroups | awk -F, '{ for (i = 1; i < NF; ++i ) print $i " " ${i}_descr " off"}'`Code: (*) group_a group_a,group_bCode: (*) group_a Description of group_aawk -F, '{ for (i = 1; i < NF; ++i ) print $i " " $i_descr " on"}' awk -F, '{ for (i = 1; i < NF; ++i ) print $i " " ${$i}_descr " on"}' awk -F, '{ for (i = 1; i < NF; ++i ) print $i " ${i}_descr" " on"}' with no success. I am open to alternatives to awk.... :) |
No comments:
Post a Comment