From 0d8cbb27628a7472a167301a9e41fe5d8305e7ed Mon Sep 17 00:00:00 2001 From: HuangKangJing Date: Sat, 7 Mar 2015 21:22:57 +0800 Subject: [PATCH] Added a stat report script. --- README.md | 5 ++++- report.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 report.sh diff --git a/README.md b/README.md index 2dc6739..e64e00b 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,10 @@ This tool can parse and dump WeChat chat history on a rooted android phone. ``` ./dump_html.py decrypted.db resource output.html ``` - ++ Generate statistical report on text messages: +``` +./report.sh message_dir +``` ### Examples: See [here](http://ppwwyyxx.com/static/wechat/example.html) for an example html. diff --git a/report.sh b/report.sh new file mode 100755 index 0000000..40e3566 --- /dev/null +++ b/report.sh @@ -0,0 +1,27 @@ +#!/bin/bash -e +# File: android-interact.sh +# Date: Sat Mar 7 20:57:51 2015 +0800 +# Author: Kangjing Huang + + +if [[ -z $1 ]] +then + echo "Usage: $0 [Directory of text messages]" + exit 1 +fi + +echo -e "Filename\tCounts of message\tCounts of chars\tCounts of words" + +SAVEIFS=$IFS +IFS=$(echo -en "\n\b") + +for i in "$1"/*.txt +do + echo -en "$i\t" + LINECOUNT=$(cat "$i"| wc -l ) + CHARCOUNT=$(cat "$i"| sed 's/.*:[0-9][0-9]:\(.*\)/\1/g' | sed 's/\[.*\]//g' | grep -v img | wc -m) + WORDCOUNT=$(cat "$i"| sed 's/.*:[0-9][0-9]:\(.*\)/\1/g' | sed 's/\[.*\]//g' | grep -v img | wc -w) + echo -e "$LINECOUNT\t$CHARCOUNT\t$WORDCOUNT" +done + +IFS=$SAVEIFS