ref: bef4f6bd8b652b434f708d287f4ed850e37b0345
parent: 6c9eb7f74993179a823f4e1c02793786d51bf773
author: qwx <qwx@sciops.net>
date: Tue Aug 11 19:02:56 EDT 2020
add typical awk approach to binary data output
--- /dev/null
+++ b/hex.awk
@@ -1,0 +1,14 @@
+#!/bin/awk -f
+function hex(s, v){
+ if(s ~ /^0x/)
+ s = substr(s, 3)
+ for(n=1; n<=length(s); n++)
+ v = v * 16 + h[substr(s, n, 1)]
+ return v
+}
+BEGIN{
+ for(n=0; n<16; n++){
+ h[sprintf("%x", n)] = n
+ h[sprintf("%X", n)] = n
+ }
+}