buddylistgrapher

view graph_sed.sh @ 12:91f3e84482fa

excluded images in .hgignore
author meillo@marmaro.de
date Sat, 09 Jun 2007 12:16:22 +0200
parents 79af6ba23e46
children fe4ccf810364
line source
1 #!/bin/bash
2 #
3 # Autor: markus schnalke (prog.marmaro.de)
4 # Autor: Julian Forster (www.ProgMaschine.de.vu)
5 #
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
35 file=/tmp/`basename $0`-$$
36 file2=/tmp/`basename $0`-$$-2
39 sed -n -e '
40 /^Profil/{
41 s/Profil von: \(.\+\)/"\1";/
42 w /tmp/aa
43 s/;$//
44 h
45 #p
46 }
49 /^Nachricht/{
50 G
51 s/ - [-0-9]\+//
52 s/Nachricht schreiben \(.\+\)\n/"\1" /
53 s/"\(.\+\)" "\(.\+\)"/ "\2" -> "\1";/
55 # write out
56 #p
57 w /tmp/bb
58 }
59 ' $1
61 echo "digraph G {"
62 grep -f /tmp/aa /tmp/bb
63 echo "}"
65 # rm $file $file2
66 rm /tmp/aa /tmp/bb
67 exit 0
69 fi
70 else
71 echo "usage: $0 <input.txt>"
72 exit 1
73 fi