In bash I'd do it like this:
Code:
#!/bin/bash
letters=({{a..z},{A..Z}})
declare -i letter=0 number=0
while read line; do
echo ${letters[$letter]}$line$(printf %04d $number)
(( ++letter == ${#letters[@]} )) && letter=0
(( ++number == 10000 )) && number=0
done
The script populates an array $letters (using brace expansion) and declares two indices: $letter (for indexing the array) and $number (for the number counter).
Then it iterates on each line of standard input echoing a string composed of: an entry of $letters indexed by $letter, followed by the $line, followed by $number (uses a command substitution to call printf, which allows for zero padding).
Finally, the last two arithmetic expressions reset $letter if it's higher than the last index of $letters, and $number if it's higher than 9999.
You can test it easily with something like:
Code:
yes | sed 's/./this is a line/' | ./scriptname
Additionaly, you can trim it some more at the expense of readability by using just one index (0 to 99999). Where you want to use it for indexing the array, use a modulus (remainder) operation to adjust it. This will also gain you some tiny extra cpu cycles:
Code:
#!/bin/bash
letters=({{a..z},{A..Z}})
declare -i index=0
while read line; do
echo ${letters[$((index % ${#letters[@]}))]}$line$(printf %04d $index)
(( ++index == 10000 )) && index=0
done