Is there an awk-like or sed-like command line hack I can issue to generate a list of all keyboard characters (such as a-zA-z0-9!-*, etc)? I’m writing a simple Caesar cipher program in my intro programming class where we do the rotation not through ASCII values, but indexing into an alphabet string, something like this:
String alphabet = "abcdefghijklmnopqrstuvwxyz";
for (int pos = 0; pos < message.length(); pos++) {
char ch = message.charAt(pos);
int chPos = alphabet.indexOf(ch);
char cipherCh = alphabet.charAt(chPos+rotation%alphabet.length());
System.out.print(cipherCh);
}
Clearly I can write a loop in some other language and print all ASCII values, but I’d love something closer to the command line as flashier example.
Is this what you’re looking for:
awk 'END {for (i=33; i<=126; i++) printf("%c",i); print ""}' /dev/nullThis generates:
I chose the range from 33 to 126 as the printable chars. See ascii man page