diff graph2.sh @ 0:21d9547ef242

initial commit C++ and sh editions work similar
author meillo@marmaro.de
date Mon, 28 May 2007 17:41:28 +0200
parents
children 6c327ae23d2c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graph2.sh	Mon May 28 17:41:28 2007 +0200
@@ -0,0 +1,56 @@
+#!/bin/bash
+# 
+# Autor: Julian Forster (www.ProgMaschine.de.vu)
+# Autor: markus schnalke (prog.marmaro.de)
+#
+
+
+if [ $# -eq 1 ]; then
+  if [ $1 = '--version' ] ; then
+    echo 'Buddylistgrapher'
+    echo 'shellscript edition'
+    echo 'version 0.1'
+    exit 0
+  else
+
+    file=/tmp/`basename $0`-$$
+    file2=/tmp/`basename $0`-$$-2
+
+    # extract all needed lines
+    grep -e "Profil von:" -e "Nachricht schreiben" $1 > $file
+
+    # collect all profil names (we only want them as nodes)
+    cat $file | while read line ; do
+      echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2
+    done
+    echo >> $file2
+
+#cat $file2
+#exit 
+
+
+    # output
+    echo "digraph G {"
+    
+    cat $file | while read line ; do
+      isProfil=`echo $line | grep "Profil von:"`
+      if [ -n "$isProfil" ] ; then
+        name=$(echo $line |  awk '{ print $3 }')
+      else
+        buddy=$(echo $line |  awk '{ print $3 }')
+        if [ -n "`grep -F " $buddy " $file2`" ] ; then
+          echo "  \"$name\" -> \"$buddy\";"
+        fi
+      fi    
+    done
+
+    echo "}"
+
+    #rm $file $file2
+    exit 0
+
+  fi
+else
+    echo "usage: $0 <input.txt>"
+    exit 1
+fi