Piece of cake. I did it with a 67-line shell script (about a fourth of which are blank). I guess it helps that I've been known to spend my days writing parsers, of course, but that script I posted a couple of days back was about 85% of the way there, and it took all of about twenty minutes to write.
Once he sent me the real data file, I just had to work around the fact that some empty entries were omitted entirely without leaving a blank line (and thus the value of "Salutation:" might appear as "First Name:" with my original hack job) and tweak the handling of the code that stripped off the first entry each time through the loop.
I mean seriously, Chance, you're going to have to at least make the problem a little harder next time....
EMAIL="$(echo "$DATA" | grep -B 1 "Salutation:" | head -n 1 | sed 's/,/-/g')"
SALUTATION="$(echo "$DATA" | grep -A 1 "Salutation:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$SALUTATION" = "xFirst Name:" ] ; then
SALUTATION="";
fi
FIRSTNAME="$(echo "$DATA" | grep -A 1 "First Name:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$FIRSTNAME" = "xLast Name:" ] ; then
FIRSTNAME="";
fi
LASTNAME="$(echo "$DATA" | grep -A 1 "Last Name:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$LASTNAME" = "xAddress Line 1:" ] ; then
LASTNAME="";
fi
ADDR1="$(echo "$DATA" | grep -A 1 "Address Line 1:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$ADDR1" = "xAddress Line 2:" ] ; then
ADDR1="";
fi
ADDR2="$(echo "$DATA" | grep -A 1 "Address Line 2:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$ADDR2" = "xCity:" ] ; then
ADDR2="";
fi
CITY="$(echo "$DATA" | grep -A 1 "City:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$CITY" = "xState:" ] ; then
CITY="";
fi
STATE="$(echo "$DATA" | grep -A 1 "State:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$STATE" = "xZip Code:" ] ; then
STATE="";
fi
ZIP="$(echo "$DATA" | grep -A 1 "Zip Code:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$ZIP" = "xCountry Code:" ] ; then
ZIP="";
fi
COUNTRY="$(echo "$DATA" | grep -A 1 "Country Code:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$COUNTRY" = "xPhone Number:" ] ; then
COUNTRY="";
fi
PHONE="$(echo "$DATA" | grep -A 1 "Phone Number:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$PHONE" = "xPhone Extension:" ] ; then
PHONE="";
fi
EXT="$(echo "$DATA" | grep -A 1 "Phone Extension:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$EXT" = "xFax Number:" ] ; then
EXT="";
fi
FAX="$(echo "$DATA" | grep -A 1 "Fax Number:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$FAX" = "xCellular Phone Number:" ] ; then
FAX="";
fi
CELL="$(echo "$DATA" | grep -A 1 "Cellular Phone Number:" | head -n 2 | tail -n 1 | sed 's/,/-/g')"
if [ "x$CELL" = "xCellular Phone Number:" ] ; then
# An odd bug that only happens on the last entry.
CELL="";
fi
# DATA="$(echo "$DATA" | perl -pi.bak -e "s/^.*?Cellular Phone Number:\n(\s|\d|[()])+\n+\s*//s")"
DATA="$(echo "$DATA" | perl -e '$/=undef;my $foo = <STDIN>; $foo =~ s/^.*?Cellular Phone Number:\n(.*?\n\s*|$)//s; print $foo;')"
# echo "DATA is \"$DATA\"";
echo "$SALUTATION $FIRSTNAME,$LASTNAME,$ADDR1,$ADDR2,$CITY,$STATE,$ZIP,$COUNTRY,$PHONE,$EXT,$FAX,$CELL,$EMAIL"