3

My ultimate goal here is to generate a block of text that can be used to test out various fonts at a terminal. I want to generate the file as basically an ascii chart. A series of characters from 1 to 255 will do, I'm not worried about bells, or white space or anything, very simple.

I know if I wanted to type out all the numbers, I could do something like this:

printf '\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a'
ABCDEFGHIJKLMNOPQRSTUVWXYZ

But I don't want to have to type them all out. I know I can use printf and seq with a sub-shell to generate some hex

printf %x' ' `seq 65 90`
41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a

Can somebody help me connect the dots here?

I don't need a formal ascii table, but I would like pretty much all the visible characters so I can better test the various fonts.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
slf
  • 133
  • 4

3 Answers3

3

POSIX one:

$ awk 'BEGIN{for(n=33;n<=90;n++)printf "%c",n}'                              
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ

Perl one:

$ perl -e 'print chr for 33..90'
cuonglm
  • 150,973
  • 38
  • 327
  • 406
1

Perhaps like this:

perl -e 'for(65..90) { printf "%c", $_ }'

Or, if you insist to do it with printf(1) on Linux:

printf $( printf '\\x%02x' $( seq 65 90 ) )

Or, with printf(1) on *BSD:

printf $( printf '\\x%02x' $( jot - 65 90 1 ) )
lcd047
  • 7,160
  • 1
  • 22
  • 33
  • thanks, I feel like I always forget about perl, I went with this: `perl -e 'for(33..79) { printf "%d\t%c\t\t%d\t%c\n", $_, $_, $_+47, $_+47 }'` – slf Jun 05 '15 at 15:06
1

With bash >= 3.0, ksh93r and above, zsh:

printf $( printf '\\x%02x' {65..90})
cuonglm
  • 150,973
  • 38
  • 327
  • 406
chaos
  • 47,463
  • 11
  • 118
  • 144