chipperMDW
Programmer
Occasionally, I'll need to write a script that does something for each letter in the alphabet. I used do something like:
That's tedious to type, and it always seemed like there should be a better way, like a [tt]seq[/tt] for letters. I recently discovered a tool called [tt]jot[/tt]. With it, I can do the following:
I was curious about what other methods people had for accomplishing the same task. I'm sure there are some nifty perl and awk one-liners.
I'm especially curious to see if there's a way to do this that doesn't involve a dependence on ASCII codes and works with POSIX [tt][:alpha:][/tt]-style character classes.
Code:
for x in a b c d e f g h i j k l m n o p q r s t u v w x y z; do
echo $x
done
That's tedious to type, and it always seemed like there should be a better way, like a [tt]seq[/tt] for letters. I recently discovered a tool called [tt]jot[/tt]. With it, I can do the following:
Code:
for x in $([highlight]jot -c 26 a[/highlight]); do # Generate 26 characters starting at ASCII 'a'
echo $x
done
I was curious about what other methods people had for accomplishing the same task. I'm sure there are some nifty perl and awk one-liners.
I'm especially curious to see if there's a way to do this that doesn't involve a dependence on ASCII codes and works with POSIX [tt][:alpha:][/tt]-style character classes.