annotate graph3.sh @ 6:e34b27b544b5

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