Q: Best way to generate a random string following a specific pattern in Bash I'm wanting to generate many six character strings all following this pattern:

[consonant][vowel][consonant][consonant][vowel][consonant]

e.g.

haplop
  github
  qursog

I've looked at various ways of doing this, but nothing I have though of so far is elegant. My thoughts mostly revolved around generating one character at a time but even then my ideas weren't really all that good due to my lack of bash scripting knowledge and obscure Linux commands.
Ideally I'm looking for a Linux command that randomly generates a string but allows me to specify the pattern shown above (if one even exists). Alternatively if you know of a simple way of doing this in bash that would also be great.
Thanks in advance
Edit: BTW, I will give this a 24 hours before choosing the accepted answer so that I have more chance of picking the best answer and not just the first (although the first answer was pretty good).

A: 
#!/bin/bash
#
#
cprint () {
    typ=$1
    case $typ in 
        v) alpha="aeiouy" ;;
        c) alpha="bcdfghjklmnpqrstvwxz" ;;
        V) alpha="AEIOUY" ;;        
        C) alpha="BCDFGHJKLMNPQRSTVWXZ" ;;
        n) alpha="0123456789" ;;
        *) echo "** Undefined **" ; exit 1 ;;
    esac
    len=${#alpha}
    r=$((RANDOM%len))
    echo -en ${alpha:r:1}
}

rprint () {
    code=$1
    for i in $(seq 1 ${#code})
    do 
        c=${code:i-1:1}
        cprint $c
    done
    echo
}

rprint "cvccvc"
rprint "cvcvvc"
rprint "Cvccvc"
rprint "Vccvcvc"
rprint "Cvnvn"

This solution is easily changed to print a different sequence, is easily redefined, if you don't agree about the y, need äöü or UPPERCASE and so on.
Experimental result:
gohhec
voteup
Wuwjut
Utpycoq
Va6a6

man bash says about RANDOM:

Each  time this parameter is referenced, a random integer between 0 and 32767 ...

So if take the modulo RANDOM % X, and X is not a power of 2, the lower remainders will have better chances than higher once. It shouldn't be important in your case, as long as you don't go to the extereme with your character groups, or use it in high security areas. :)

A: Here is how you could generate a vowel:
s=aeiou
p=$(( $RANDOM % 5))
c=${s:$p:1}

Use the same method for consonants.
You can wrap this into a small function:
function vowel() {
    s=aeoiu
    p=$(( $RANDOM % 5))
    echo -n ${s:$p:1}
}

And then you have a nice pattern to generate the string:
s=`consonant; vowel; consonant; vowel; consonant; vowel`


A: For posterity, I'll include the code I ended up with. It mostly uses Karoly Horvath's code, but I also added some ideas from "user unknown":
#!/bin/bash
function v() {
    s=aeoiuy
    p=$((RANDOM % ${#s}))
    echo -n ${s:$p:1}
}

function c() {
    s=bcdfghjklmnpqrstvwxz
    p=$((RANDOM % ${#s}))
    echo -n ${s:$p:1}
}

function genPatternStrings() {
    for i in $(eval echo {0..$1}); do
        echo `c;v;c;c;v;c;`
    done
}

genPatternStrings $1;


A: Though the following command doesn't answer the original question, it may be useful in other cases to generate any random string:
for i in {1..15}; do     # 15 random strings
    dd status=noxfer if=/dev/random bs=1 count=200 2>/dev/null |
    tr -dc 'a-z0-9A-Z' | # alphanumerics only
    cut -b1-10 |         # length 10
    tr 'A-Z' 'a-z'       # lowercase
done | less

