forked from unixnut/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelm-pager.awk
executable file
·56 lines (54 loc) · 1.94 KB
/
elm-pager.awk
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
BEGIN { substitutes["Automatic digest processor"] = "WotC's listserv" }
NR == 1 {
print $2
elm_line = $0
if ($3 == "From")
{
extra_blanks = 1;
crap_length = length( $1 $2 ) + 8
}
else
crap_length = length( $1 $2 ) + 2
}
NF == 0 {
++instance
if (instance == 2 + extra_blanks)
{
print NR + 1
name = substr( elm_line, crap_length + 1, \
80 - crap_length - elm_date_length );
ds_pos = index( name, " " )
if (ds_pos > 0)
name = substr( name, 1, ds_pos - 1 )
if (substitutes[name] != "")
name = substitutes[name]
subject_field_length = 52 - 2 * length( LINES ) - \
length( name )
if (subject == "")
subject = "<no subject>"
subject = subject " "
printf "line ^^^lt/^^^L | %s | %s | %s\n", date, name,\
substr( subject, 1, subject_field_length ) \
> "/tmp/me2." PID
exit
}
}
/^Date:/ {
elm_date_length = length( $0 ) - 7
if (NF == 4)
date = $2
else
if (NF == 6)
date = $3 " " $2 " " $6
else
{
date = $3 " " $4 " " $5
if ($3 < 10)
elm_date_length = length( $0 ) - 10
else
elm_date_length = length( $0 ) - 9
}
}
/^Subject:/ {
subject = substr( $0, 10 )
}