vendredi 4 mars 2016

How to avoid multiple OR statement bash

I have GUI check list for parameters to use grep search. When you check the list - this parameter should show up in grep control option.

For example:

w=TRUE or FALSE
s=TRUE or FALSE
N=TRUE or FALSE
L=TRUE or FALSE

And I would like to use all combination of check list selection something like:

if [ "$w" == TRUE ]; then

grep -w searsch_pattern INFILE


elif [ "$w" == TRUE ] && [ "$s" == TRUE ];then

grep -w -s searsch_pattern INFILE

....

fi

My question is if possible to avoid write all combination elif statement and found some more elegant solution.

PS: I want to use more then four output control parameters in grep search.

Thank you for any help.

Aucun commentaire:

Enregistrer un commentaire