From 7e46d2040a696f7475dcf34c56bd394a4a6c1f8d Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Wed, 16 Feb 2011 13:52:47 +0100 Subject: [PATCH] New file format The new file format allows us to sort entries correctly, even if entry IDs are "out of order", for example after changing devices. --- iPhone2Mac.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/iPhone2Mac.sh b/iPhone2Mac.sh index 0cf3ea4..4070cc6 100755 --- a/iPhone2Mac.sh +++ b/iPhone2Mac.sh @@ -1,7 +1,7 @@ #!/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 @@ -53,13 +53,27 @@ import_d() { 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." } -- 2.39.2