Grep the last line and put on mail subject

I have mail:
cat /home/oracle/scripts/dbsizedaily.txt | mail -s "$TODAY: PROD DB Size" $RECIPIENTS

I like to get and put USED_GB and %USED of the very last row from /home/oracle/scripts/dbsizedaily.txt .

/home/oracle/scripts/dbsizedaily.txt has :

DATE      TIME       TOTAL_GB    USED_GB      %USED
......                     
03/05/2013 21:13 PM 3151.24316 2329.82947 73.9336619                        
03/05/2013 21:17 PM 3151.24316 2330.17322 73.9445703

so that e-mail subject that contain
"DATE: 03/06/13 - PROD DB Size: 2,330.17 GB - %USED:73.94"

Please advise.

grep matches regular expressions, it doesn't understand concepts like the 'last line'.

awk does however. I'd try this:

awk '{ L=$0 } END { $0=L ; print "DATE: "$1,"PROD DB SIZE: "$5,"%USED:"$6 }' OFS=" - " /home/oracle/scripts/dbsizedaily.txt |
        mail -s "$TODAY: PROD DB Size" $RECIPIENTS

OR use tail and cut to get those field values:

USED_DB=$(tail -1 /home/oracle/scripts/dbsizedaily.txt | cut -d' ' -f5)
USED_PC=$(tail -1 /home/oracle/scripts/dbsizedaily.txt | cut -d' ' -f6)

cat /home/oracle/scripts/dbsizedaily.txt | mail -s "$TODAY: PROD DB Size: $USED_DB - %USED: $USED_PC"

Is there any way to format the number into two decimals with a comma so that they show as PROD DB Size: 2,330.17 GB - %USED:73.94 rather than PROD DB Size: 2330.17322 - %USED: 73.9445703 ?

You can use printf to format the number to 2 decimal places and include thousand separators:

USED_DB=$( printf "%'.2f" $USED_DB )
USED_PC=$( printf "%'.2f" $USED_PC )

---------- Post updated at 17:16 ---------- Previous update was at 17:13 ----------

From printf manual:

A block size specification preceded by `'' causes output sizes to be
displayed with thousands separators.  The `LC_NUMERIC' locale specifies
the thousands separator and grouping.  For example, in an American
English locale, `--block-size="'1kB"' would cause a size of 1234000
bytes to be displayed as `1,234'.  In the default C locale, there is no
thousands separator so a leading `'' has no effect.

A little experiment:

awk 'END {print "\"DATE: "$1 "- PROD DB SIZE: ", $5+0, "- %USED:", $6-0, "\" ", REC |"mail -s"}' OFMT="%.2f" REC=$RECIPIENTS /home/oracle/scripts/dbsizedaily.txt

I would recommend to use tail, cut, and printf, as previously suggested.