-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable-ascii
executable file
·40 lines (34 loc) · 1.03 KB
/
table-ascii
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# ascii.sh
# ver. 0.2, reldate 26 Aug 2008
# Patched by ABS Guide author.
# Original script by Sebastian Arming.
# Used with permission (thanks!).
#exec >ASCII.txt # Save stdout to file,
#+ as in the example scripts
#+ reassign-stdout.sh and upperconv.sh.
MAXNUM=256
COLUMNS=5
OCT=8
OCTSQU=64
LITTLESPACE=-3
BIGSPACE=-5
i=1 # Decimal counter
o=1 # Octal counter
while [ "$i" -lt "$MAXNUM" ]; do # We don't have to count past 400 octal.
paddi=" $i"
echo -n "${paddi: $BIGSPACE} " # Column spacing.
paddo="00$o"
# echo -ne "\\${paddo: $LITTLESPACE}" # Original.
echo -ne "\\0${paddo: $LITTLESPACE}" # Fixup.
# ^
echo -n " "
if (( i % $COLUMNS == 0)); then # New line.
echo
fi
((i++, o++))
# The octal notation for 8 is 10, and 64 decimal is 100 octal.
(( i % $OCT == 0)) && ((o+=2))
(( i % $OCTSQU == 0)) && ((o+=20))
done
exit $?