Linux, Unix, /etc

Danger Will Robinson! You are now entering a condescending Unix user zone!
Sponsored links (requires javascript):

Scripts: E-mail

linkify: make links in an e-mail clickable

#!/bin/sh
#linkify: make links in an e-mail clickable
show -noshowproc $* | rmhdr | urlify > /tmp/$$.html
lynx /tmp/$$.html
rm /tmp/$$.html

Very handy if you hate HTML e-mail, but nevertheless from time to time get e-mails full of urls — it's nice to be able to just follow the link in that case. Note the use of pre-existing scripts chained together in a pipe: it's The Unix Way.


urlify: convert urls in a text file to browser-parseable html

#!/bin/sed -f
#urlify: convert urls in a text file to browser-parseable html
1i\
<pre>
s/\(http:\/\/[^ ]*\)/<a href="\1">\1<\/a>/g
$a\
</pre>


rmhdr: remove the header from e-mail or news messages

Only removes the first header from a file containing multiple messages, obviously.

 
#!/bin/sed -f
1,/^$/d

If you've got a bunch of e-mails in one file, then to strip all the headers, do:

 
#!/bin/sed -f
/^From: /,/^$/d


todaysmail: lists mail received today

 
#!/bin/sh
#todays-mail: lists mail received today, as stored in user's procmail log
procmaillog=$HOME/.procmail/log
# first is portable, second is faster but specific to GNU date
#today=`date +'%a %b %d'|sed 's/0\([1-9]\)/ \1/'`
progname=`basename $0`
case $progname in
    today*) today=`date +'%a %b %_d'` ;;
    yesterday*) today=`date +'%a %b %_d' —date '1 day ago'` ;;
esac
#grep "$today" $procmaillog
tail -2000 $procmaillog | grep "$today" 


mailq-c: count number of entries in mailq

I wrote this years ago. Later versions of sendmail report this as a footer to the mailq command anyway.

 
#!/bin/sh
#mailq-c: count number of entries in mailq
mailq |
sed -e '1{
s/[^0-9]*\([0-9][0-9]*\)[^0-9]*/\1/
q
}'


isspam: ... so deal with it

This uses the splendid little Unix filter, bfilter, a Bayesian analysis program that successfully dumpbs about 99% of my spam into a special bin.

#!/bin/sh
#isspam: ... so deal with it
case $* in
    "") show -noshowproc +inbox cur | bfilter isspam && refile +spam ;;
esac
for i in $*
do
    show -noshowproc $i | bfilter isspam && refile +spam
done
folder +spam last
folder +inbox


[back to Scripts index] [back to Linux, Unix, etc] [Main Site] [Weblog]



Contents licensed under the GPL