buddylistgrapher

view 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 source
1 #!/bin/bash
2 #
3 # Autor: Julian Forster (www.ProgMaschine.de.vu)
4 # Autor: markus schnalke (prog.marmaro.de)
5 #
8 if [ $# -eq 1 ]; then
9 if [ $1 = '--version' ] ; then
10 echo 'Buddylistgrapher'
11 echo 'shellscript edition'
12 echo 'version 0.1'
13 exit 0
14 else
16 file=/tmp/`basename $0`-$$
17 file2=/tmp/`basename $0`-$$-2
19 # extract all needed lines
20 grep -e "Profil von:" -e "Nachricht schreiben" $1 > $file
22 # collect all profil names (we only want them as nodes)
23 cat $file | while read line ; do
24 echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2
25 done
26 echo >> $file2
28 #cat $file2
29 #exit
32 # output
33 echo "digraph G {"
35 cat $file | while read line ; do
36 isProfil=`echo $line | grep "Profil von:"`
37 if [ -n "$isProfil" ] ; then
38 name=$(echo $line | awk '{ print $3 }')
39 else
40 buddy=$(echo $line | awk '{ print $3 }')
41 if [ -n "`grep -F " $buddy " $file2`" ] ; then
42 echo " \"$name\" -> \"$buddy\";"
43 fi
44 fi
45 done
47 echo "}"
49 #rm $file $file2
50 exit 0
52 fi
53 else
54 echo "usage: $0 <input.txt>"
55 exit 1
56 fi