Skip to content

Instantly share code, notes, and snippets.

@yqt
Last active October 15, 2019 09:36
Show Gist options
  • Save yqt/6c7e9f5b32c9fa0a3e2f186362d696ca to your computer and use it in GitHub Desktop.
Save yqt/6c7e9f5b32c9fa0a3e2f186362d696ca to your computer and use it in GitHub Desktop.
awk every N lines into one with delimiter
grep -E 'symptom_id|symptom_name|symptom_alias' encyclopedias.xml* | awk -F '[\\[\\]]' '{line=line "\t" $3} NR%3==0{print substr(line,2); line=""}'
cat symptom.jl | python2.7 -c 'import sys; reload(sys); sys.setdefaultencoding("utf-8"); import json; [sys.stdout.write(json.dumps(json.loads(i)["symptom"], ensure_ascii=False, indent=4, sort_keys=True) + "\n") for i in sys.stdin]' | grep -E '"chineseName"|"englishName"|"id"|"otherName"' | awk -F '[: ,]' '{line=line "\t" $7} NR%4==0{print substr(line,2); line=""}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment