to make the above an executable here is the code for a bash file
place this code in a file named similar to "emailheader"
use nano to create the file nano -w -c emailheader
cut and paste the code in it
make sure there is no blank lines at the top of the file
close nano with ctrl-x
last, make the file executable with chmod +x emailheader
run the program with a email file name on the command line
emailheader filename
#!/bin/bash
filename="$*"
if [ -f "$filename" ] && [ -e "$filename" ] && [ -r "$filename" ]
then
echo -e "$(grep -B10000 -m1 ^$ "$filename" | tr -s '\t' '\040'|sed -e ':a;N;$!ba;s/\n / /g')"
exit 0
else
exit 1
fi