OILS / benchmarks / javascript / hexstring.sh View on Github | oilshell.org

38 lines, 29 significant
1#!/usr/bin/env bash
2
3hexdigits='0123456789abcdef'
4for c in {0..9} {a..f}; do
5 for d in {0..9} {a..f}; do
6 for e in {0..9} {a..f}; do
7 hexbyte=$c$d$e
8
9 byte=$hexbyte
10 byte=${byte//0/0000}
11 byte=${byte//1/0001}
12 byte=${byte//2/0010}
13 byte=${byte//3/0011}
14
15 byte=${byte//4/0100}
16 byte=${byte//5/0101}
17 byte=${byte//6/0110}
18 byte=${byte//7/0111}
19
20 byte=${byte//8/1000}
21 byte=${byte//9/1001}
22 byte=${byte//a/1010}
23 byte=${byte//b/1011}
24
25 byte=${byte//c/1100}
26 byte=${byte//d/1101}
27 byte=${byte//e/1110}
28 byte=${byte//f/1111}
29
30 #echo $byte)
31
32 ones=${byte//0/}
33 if test ${#ones} -eq 11; then
34 echo $hexbyte $byte
35 fi
36 done
37 done
38done