UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 35.4 recomment: Clean Up Program Comment Blocks Chapter 35
You Can't Quite Call This Editing
Next: 35.6 Low-Level File Butchery with dd
 

35.5 Remove Mail/News Headers with behead

When you're saving or re-sending a news article or mail message (1.33), you might want to the remove header lines (Subject:, Received:, and so on). This little script will handle standard input, one or many files. It writes to standard output. Here are a few examples:

Here's the script, adapted a little from the original by Arthur David Olson:


#! /bin/sh
case $# in
0)  exec sed '1,/^$/d' ;;
*)  for i
    do sed '1,/^$/d' "$i"
    done
    ;;
esac

The script relies on the fact that mail messages use a blank line to separate the header from the body of the message. As a result, the script simply deletes the text from the beginning up to the first blank line.

- JP


Previous: 35.4 recomment: Clean Up Program Comment Blocks UNIX Power ToolsNext: 35.6 Low-Level File Butchery with dd
35.4 recomment: Clean Up Program Comment Blocks Book Index35.6 Low-Level File Butchery with dd

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System