Skip to content

Instantly share code, notes, and snippets.

@koduki
Last active December 14, 2016 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koduki/dc78b228d1418e01ac6fe4a3db9d8483 to your computer and use it in GitHub Desktop.
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)
#!/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