vendredi 18 décembre 2020

Create if in if while using loop in bash

I'm curious is it possible to some how create if in if while using BASH ?

What I mean is, lets say I have an array that has values 1, 2, 3 in it. What I want to do is to create a loop that goes through all of those values and creates if in if statement. Like after first iteration output should look like this:

if value = 1; then
   :
else
   :
fi

After second loop iteration another if is appended to previous if, like this:

if value = 1; then
   if value = 2; then
      :
   else
      :
   fi
else
   :
fi

and so on and on. Any ideas?

Aucun commentaire:

Enregistrer un commentaire