| 1 | #!/bin/bash |
| 2 | # from.sh |
| 3 | |
| 4 | # Emulates the useful 'from' utility in Solaris, BSD, etc. |
| 5 | # Echoes the "From" header line in all messages |
| 6 | #+ in your e-mail directory. |
| 7 | |
| 8 | |
| 9 | MAILDIR=~/mail/* # No quoting of variable. Why? |
| 10 | # Maybe check if-exists $MAILDIR: if [ -d $MAILDIR ] . . . |
| 11 | GREP_OPTS="-H -A 5 --color" # Show file, plus extra context lines |
| 12 | #+ and display "From" in color. |
| 13 | TARGETSTR="^From" # "From" at beginning of line. |
| 14 | |
| 15 | for file in $MAILDIR # No quoting of variable. |
| 16 | do |
| 17 | grep $GREP_OPTS "$TARGETSTR" "$file" |
| 18 | # ^^^^^^^^^^ # Again, do not quote this variable. |
| 19 | echo |
| 20 | done |
| 21 | |
| 22 | exit $? |
| 23 | |
| 24 | # You might wish to pipe the output of this script to 'more' |
| 25 | #+ or redirect it to a file . . . |