How to process multiple levels of results with a single loop in bash? -


i need create loop extend describe network nodes. loop part of else not relevant topic. know in network 1 node connected , on. have these nodes in separate files , need process them loop. each loop produce more results within need perform more loops , number increases exponentially until breaking point reach. know how solve problem 50 nested loop's this:

declare loopvarnode=($(some command list of nodes)) in ${loopvarnode[@]}                 declare check1=($(grep ${a[@]} results.file))         if [[ "$a" == "breaking point" ]]         echo "match found"; break         elif [[ ! $check1 -z ]]         continue         fi         echo ${a[@]} >> results.file         declare loopvarnode1=($(same thing results in provided variable $a))         b in ${loopvarnode1[@]}                         declare check2=($(grep ${b[@]} results.file))             if [[ "$b" == "breaking point" ]]             echo "match found"; break             elif [[ ! $check1 -z ]]             continue             fi             echo ${b[@]} >> results.file             declare loopvarnode2=($(same thing results in provided variable $b))             c in ${loopvarnode2[@]}                  ..... 

after 50 of these suppose should fine maybe there's way 1 or 2 loops.

you can use recursive function instead of copy-paste same loop:

 //$1 first list parameter.      function do_things {           in ${$1[@]}               declare check1=($(grep ${a[@]} results.file))         if [[ "$a" == "breaking point" ]]         echo "match found"; break         elif [[ ! $check1 -z ]]         continue         fi         echo ${a[@]} >> results.file         declare loopvarnode1=($(same thing results in provided variable $a))         do_things loopvarnode1       done  }  

something that.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -