Multiple lines of data?

I use this to get 8 random letters:

cat /dev/urandom | tr -dc 'A-Z' | fold -w 8 | head -n 1

Result is,
WLGFJFZY

What I'm trying to do is get 10 lines of random letters, separated by a line and each block having ascending numbers
i.e;

00
IWMTDFIM

01
KZZZCHPQ

02
YBTGFHGT

03
OAOXSDMR

etc, etc..

(Thanks).

$ cat /dev/urandom | tr -dc 'A-Z' | fold -w 8 | awk ' { if(NR < 11) { printf("%02d\n%s\n\n",NR,$0) } else { exit} } '
01
STUVMDHN

02
IHLVHDGD

03
RDZMKZVS

04
MLPNBHCD

05
QWCPAZRD

06
SLYHEVSE

07
GESUXXOO

08
FXMABYFF

09
GKKTGYJH

10
IRIPGRXY

1 Like

Thanks. Another question: what part of the code can I alter to make more than 10 lines? Say, 50? (couldn't find a '10' in the code...)

I figured it out: 50 would be;

if(NR < 51)

:slight_smile:

Thanks again!

1 Like

Best to specify the character classification:

LC_CTYPE=C tr -dc 'A-Z' < /dev/urandom | .....
1 Like