Last active
December 14, 2016 17:27
-
-
Save koduki/dc78b228d1418e01ac6fe4a3db9d8483 to your computer and use it in GitHub Desktop.
This is AWK wrapper to parse LTSV. more details [awkとシェルでLTSVの取り扱いを簡単にするフィルタを書いてみた](http://koduki.hatenablog.com/entry/2013/07/31/000817)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
script=$1 | |
func_ltsv=`cat << 'EOS' | |
function ltsv(key){ | |
for(i=1; i<=NF; i++){ | |
match($i, ":"); | |
xs[substr($i, 0, RSTART)] = substr($i, RSTART+1); | |
}; | |
return xs[key":"]; | |
} | |
EOS` | |
# main | |
awk -F'\t' "${func_ltsv} ${script}" < /dev/stdin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment