forked from fboxwala/bashscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
formatlogs
executable file
·43 lines (22 loc) · 843 Bytes
/
formatlogs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
sed 's/<span class="user">/\n/g' ${1} > temp1
sed -n "/div class=\"thread\">${2}/=" temp1 > linenumbers
x=0
for line in `cat linenumbers`; do
tail -n +${line} temp1 > block${x}
l=`grep -n "<div class=\"thread\">" block${x} | cut -f1 -d: | head -2 | tail -n +2`
head -${l} block${x} > blocks${x}
x=$(($x+1))
done
tac blocks* > temp0
egrep "^(Patrick|Fatema)" temp0 > temp1
sed 's/<\/span><span class="meta">/\n/g' temp1 > temp2
sed 's/<\/span><\/div><\/div><p>/\n\n/g' temp2 > temp3
sed 's/<\/p><div class="message"><div class="message_header">/\n/g' temp3 > temp4
sed 's/'/`/g' temp4 > temp5
sed 's/"/"/g' temp5 > temp6
sed 's/<\/p><\/div><div class="thread">.*<div class="message"><div class="message_header">/\n/g' temp6 > temp7
sed 's/</</g' temp7 > fulltext
rm linenumbers
rm temp*
rm block*