#!/bin/bash
#
# iPhone2Mac -- save call logs from iPhone backups
-# Copyright (c)2009 Alexander Barton (alex@barton.de).
+# Copyright (c)2009-2011 Alexander Barton (alex@barton.de).
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
fi
for f in $call_db; do
verbose "Dumping SQLite call databse \"$f\" ..."
- sqlite3 "$f" "select * from call;" >>"$CALL_TMP"
+ sqlite3 "$f" "select * from call;" | while read row; do
+ IFS="|"
+ arr=($row)
+ unset IFS
+
+ rowid=${arr[0]}
+ address=${arr[1]}
+ date=${arr[2]}
+ duration=${arr[3]}
+ flags=${arr[4]}
+ id=${arr[5]}
+
+ echo "$date|$rowid|$address|$duration|$flags|$id" \
+ >>"$CALL_TMP"
+ done
done
verbose "Sorting plain ASCII call log ..."
- sort -u "$CALL_TMP" >"$CALL_LOG"
+ sort -un "$CALL_TMP" >"$CALL_LOG"
rm -f "$CALL_TMP"
- first_d=$(date -r `head -1 "$CALL_LOG" | cut -d'|' -f3` "+%Y-%m-%d %H:%M")
- last_d=$(date -r `tail -1 "$CALL_LOG" | cut -d'|' -f3` "+%Y-%m-%d %H:%M")
+ first_d=$(date -r `head -1 "$CALL_LOG" | cut -d'|' -f1` "+%Y-%m-%d %H:%M")
+ last_d=$(date -r `tail -1 "$CALL_LOG" | cut -d'|' -f1` "+%Y-%m-%d %H:%M")
message `wc -l "$CALL_LOG" | awk '{print \$1}'`" unique entries logged, from $first_d to $last_d."
}