LDP/LDP/guide/docbook/abs-guide/from.sh

26 lines
770 B
Bash
Raw Normal View History

2007-11-08 15:53:07 +00:00
#!/bin/bash
# from.sh
2012-04-04 22:51:18 +00:00
# Emulates the useful 'from' utility in Solaris, BSD, etc.
2007-11-08 15:53:07 +00:00
# Echoes the "From" header line in all messages
#+ in your e-mail directory.
MAILDIR=~/mail/* # No quoting of variable. Why?
2012-04-04 22:51:18 +00:00
# Maybe check if-exists $MAILDIR: if [ -d $MAILDIR ] . . .
2007-11-08 15:53:07 +00:00
GREP_OPTS="-H -A 5 --color" # Show file, plus extra context lines
#+ and display "From" in color.
TARGETSTR="^From" # "From" at beginning of line.
for file in $MAILDIR # No quoting of variable.
do
grep $GREP_OPTS "$TARGETSTR" "$file"
# ^^^^^^^^^^ # Again, do not quote this variable.
echo
done
exit $?
2011-08-29 23:59:19 +00:00
# You might wish to pipe the output of this script to 'more'
#+ or redirect it to a file . . .