-3

I know how to print all letters

{a..z} and {A..Z} and {0..9}

But is there a way to print all possible ASCII Characters via a bash loop?

3 Answers3

3

If it is okay to use awk:

awk 'BEGIN{for (i=32;i<127;i++) printf("%c", i)}'

Or using printf:

for((i=32;i<127;i++)) do printf "\x$(printf %x $i)"; done
ssemilla
  • 3,900
  • 12
  • 28
3

You don't need a loop

echo -e \\x{0..7}{{0..9},{A..F}}

It prints all chars from 0 to 127.

oguz ismail
  • 1
  • 16
  • 47
  • 69
1

use this:

for ((i=32;i<127;i++)) do printf "\\$(printf %03o "$i")"; done;printf "\n"
mahradbt
  • 364
  • 1
  • 2
  • 12