Skip to content

Instantly share code, notes, and snippets.

@greymd greymd/script.sh
Last active May 16, 2018

Embed
What would you like to do?
Convert app.log to csv
sed '/response:/{:loop;N;/<\/root>/!b loop;s/\n//g}' app.log | \
# 特定の時間帯のログだけをgrep
grep '^2017-05-09 20:5[0-9]' | \
# あとはgrepなりsedなりawkなりで自由に抽出
grep -oP '<record> *\K.*?(?= *</record>)' | sed 's/<\/[^>]*> *<[^>]*>/,/g;s/<[^>]*>//g'
# 同じディレクトリにapp.logを置いて実行
# $ bash script.sh
# 出力結果:
# A001,1990-01-04,0
# A002,2017-04-01,1
# A003,1995-03-20,0
# A004,2000-02-20,0
# A005,2001-12-20,1
# A006,2010-02-01,0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.