回复 1# lionfun
try:- echo 'server_list = array (serv_1,2,3,serv_4,5,8,9);' |\
- awk -v S="7" -F, '{for(i=1;i<NF;i++)if(gensub("serv_","","g",S)<T=gensub(/.*\(|serv_/,"","g",$i)){sub(T,S","T,$i);break}}1' OFS=,
- server_list = array (serv_1,2,3,serv_4,5,7,8,9);
- echo 'server_list = array (serv_1,2,3,serv_4,5,8,9);' |\
- awk -v S="serv_6" -F, '{for(i=1;i<NF;i++)if(gensub("serv_","","g",S)<T=gensub(/.*\(|serv_/,"","g",$i)){sub(T,S","T,$i);break}}1' OFS=,
- server_list = array (serv_1,2,3,serv_4,5,serv_6,8,9);
复制代码 |