comparison graph_sed.sh @ 13:fe4ccf810364

some cleanups in sed-variant
author meillo@marmaro.de
date Sat, 09 Jun 2007 12:20:43 +0200
parents 3af263aed951
children
comparison
equal deleted inserted replaced
12:91f3e84482fa 13:fe4ccf810364
33 else 33 else
34 34
35 file=/tmp/`basename $0`-$$ 35 file=/tmp/`basename $0`-$$
36 file2=/tmp/`basename $0`-$$-2 36 file2=/tmp/`basename $0`-$$-2
37 37
38 38
39 sed -n -e ' 39 # sed
40 sed -n -e "
40 /^Profil/{ 41 /^Profil/{
41 s/Profil von: \(.\+\)/"\1";/ 42 s/Profil von: \(.\+\)/\"\1\";/
42 w /tmp/aa 43 w $file
43 s/;$// 44 s/;$//
44 h 45 h
45 #p 46 #p
46 } 47 }
47 48
48 49
49 /^Nachricht/{ 50 /^Nachricht/{
50 G 51 G
51 s/ - [-0-9]\+// 52 s/ - [-0-9]\+//
52 s/Nachricht schreiben \(.\+\)\n/"\1" / 53 s/Nachricht schreiben \(.\+\)\n/\"\1\" /
53 s/"\(.\+\)" "\(.\+\)"/ "\2" -> "\1";/ 54 s/\"\(.\+\)\" \"\(.\+\)\"/ \"\2\" -> \"\1\";/
54 55
55 # write out 56 # write out
56 #p 57 #p
57 w /tmp/bb 58 w $file2
58 } 59 }
59 ' $1 60 " $1
60 61
62 # output
61 echo "digraph G {" 63 echo "digraph G {"
62 grep -f /tmp/aa /tmp/bb 64 grep -f $file $file2
63 echo "}" 65 echo "}"
64 66
65 # rm $file $file2 67 # cleanup
66 rm /tmp/aa /tmp/bb 68 rm $file $file2
67 exit 0 69 exit 0
68 70
69 fi 71 fi
70 else 72 else
71 echo "usage: $0 <input.txt>" 73 echo "usage: $0 <input.txt>"