while pondering how it might be possible to (re)write kv.awk
while preserving line ordering and processing the file in more traditional `awk like filtering style
i ended up using the below method(s) to allow prototyping/editing the script from the command line
print script without shebang
awk '{if( NR != 1 ) print $0}' ./kv.awk
run script in awk
busybox awk "$(awk '{if( NR != 1 ) print $0}' ./kv.awk)"
...
https://github.com/Gumnos/kv.awk # A dumb key/value store implemented in awk & plain-text files
as previously mentioned @
https://forum.tinycorelinux.net/index.php/topic,25301.msg171402.html#msg171402https://raw.githubusercontent.com/Gumnos/kv.awk/master/kv.awksome small changes after some testing
diff -ud ./kv.awk-orig ./kv.awk >kv-patch
kv-patch attached .. as the forum server didnt like code section
more EG
---
quit printing script when BEGIN is found , and append some extra to the end of the script
echo some input
run script
setting KEY abc to VALUE xyz
echo un du trois | DEBUG=y busybox awk "$(awk '{if( $0 ~ "^BEGIN" ) exit; if( NR != 1 ) print $0}' ./kv.awk)"'BEGIN{ main() }; {print $0}' test.txt set abc xyz
get value of key abc
also pass unknown key !
echo abcd | DEBUG=y busybox awk "$(awk '{if( $0 ~ "^BEGIN" ) exit; if( NR != 1 ) print $0}' ./kv.awk)"'BEGIN{ main() }; {print $0}' test.txt get abc cde
any one resorted similar methods ?
or have i over done the eucalyptus!??
*sings* La mer