Mercurial > buddylistgrapher
comparison graph3.sh @ 4:b82703cc3dd4
added sed edition but still incomplete
author | meillo@marmaro.de |
---|---|
date | Mon, 28 May 2007 23:09:06 +0200 |
parents | |
children | e34b27b544b5 |
comparison
equal
deleted
inserted
replaced
2:6c327ae23d2c | 4:b82703cc3dd4 |
---|---|
1 #!/bin/bash | |
2 # | |
3 # Autor: markus schnalke (prog.marmaro.de) | |
4 # Autor: Julian Forster (www.ProgMaschine.de.vu) | |
5 # | |
6 | |
7 | |
8 if [ $# -eq 1 ]; then | |
9 if [ $1 = '--version' ] ; then | |
10 echo 'Buddylistgrapher (sed)' | |
11 echo '======================' | |
12 echo 'version 0.1' | |
13 echo | |
14 echo 'by Julian Forster (http://progmaschine.de.vu)' | |
15 echo 'and Markus Schnalke (http://prog.marmaro.de)' | |
16 exit 0 | |
17 elif [ $1 = '--help' ] ; then | |
18 echo 'Buddylistgrapher (sed)' | |
19 echo '======================' | |
20 echo | |
21 echo "usage: $0 <input.txt>" | |
22 echo | |
23 echo "The grapher generates output to stdout." | |
24 echo "This output is the input for the graphviz tools." | |
25 echo | |
26 echo "You can use it like this:" | |
27 echo "$0 input.txt | dot -Tpng > pic.png" | |
28 echo | |
29 echo "ToDo:" | |
30 echo "The program was written for one specific kind of input data," | |
31 echo "so there is still some work to do to use it for general input." | |
32 exit 0 | |
33 else | |
34 | |
35 file=/tmp/`basename $0`-$$ | |
36 file2=/tmp/`basename $0`-$$-2 | |
37 | |
38 # # collect all profil names (we only want them as nodes) | |
39 # cat $file | while read line ; do | |
40 # echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2 | |
41 # done | |
42 # echo >> $file2 | |
43 | |
44 | |
45 # TODO: fetch only edges for people having a profile | |
46 | |
47 # output | |
48 echo "digraph G {" | |
49 | |
50 sed -n -e ' | |
51 /^Profil/{ | |
52 s/Profil von: \(.\+\)/"\1"/ | |
53 h | |
54 #p | |
55 } | |
56 | |
57 | |
58 /^Nachricht/{ | |
59 G | |
60 s/ - [-0-9]\+// | |
61 s/Nachricht schreiben \(.\+\)\n/"\1" / | |
62 s/"\(.\+\)" "\(.\+\)"/ "\2" -> "\1";/ | |
63 | |
64 # write out | |
65 p | |
66 } | |
67 ' $1 | |
68 | |
69 | |
70 echo "}" | |
71 | |
72 # rm $file $file2 | |
73 exit 0 | |
74 | |
75 fi | |
76 else | |
77 echo "usage: $0 <input.txt>" | |
78 exit 1 | |
79 fi |