From 215d095f88c0cdc3fd65ae7e3f5c8d87a535481c Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 11 Feb 2017 02:13:43 -0500 Subject: research/split.sh: New file --- diff --git a/research/split.sh b/research/split.sh new file mode 100644 index 0000000..9a3aed3 --- /dev/null +++ b/research/split.sh @@ -0,0 +1,18 @@ +US="$(printf '\037.')"; US="${US%.}" + +buf='Hello, world!' + +printf '%s' "${buf}" | sed "s/\\(.\\)/\\1${US}/g" | \ + awk -v FS="${US}" -v j=0 -v squote="'" -v esc_squote="'\\\\''" ' + { + for (i = 1; i <= NF; ++i) { + if ($i == "") { + continue; + } + sub(squote, esc_squote, $i); + printf("lbufv_%d=" squote "%s" squote "\n", + j++, $i); + }; + printf("lbufv_%d=" squote "\n" squote "\n", j++); + } + ' -- cgit v0.9.1