mercredi 8 juin 2016

Generate Strings in Pattern

I am trying to generate some strings like

AAAA0000
AAAA0001
...
..
...
ZZZZ9999

I can do it with below logic & it will work

   for A in {A..Z}
    do
        for B in {A..Z}
            do
                for C in {A..Z}
                    do
                    for D in {A..Z}
                        do
                        for E in {0..9}
                            do
                            for F in {0..9}
                                do
                                for G in {0..9}
                                    do
                                        for H in {0..9}
                                        do
                                            echo $A$B$C$D$E$F$G$H

                                        done
                                    done
                                done
                            done
                        done
                    done
                done
            done
        done
    done

This is exhausting way of doing it (Though it solves the problem)

Can anyone help in some efficient way of doing same




Aucun commentaire:

Enregistrer un commentaire