Awk program: ascii

This Awk program prints the ASCII character table.



#!/usr/bin/env -S awk -f
# ascii - print an ASCII table.
# ascii is Copyright Joseph Steinhauser & Daniel K. Allen, 2024.
# All rights reserved.
#
# 28 Jun 2024 - Adapted by Dan Allen from Joseph Steinhauser's script.
# 30 Jun 2024 - Changed from bash to awk.
#

BEGIN {
 ab = "soh,stx,etx,eot,enq,ack,bel,bs,tab,lf,vt,ff,cr,so,si,dle,"
 ad = "dc1,dc2,dc3,dc4,nak,syn,etb,can,em,sub,esc,fs,gs,rs,us,sp"
 split(ab ad,abr,",")
 abr[0] = "nul"; abr[127] = "del"
 fm1 = "|%4d %-3s"
 for (idx = 0; idx < 128; idx++) {
   fmt = fm1 (++colz%8?"":"|\n")
   printf(fmt, idx, (idx in abr) ? abr[idx] : sprintf("%c",idx))
 }
}


Back to Dan Allen's home page.
Created:  30 Jun 2024
Modified: 14 Jul 2024