I have written a Bash script to sync all files from a local folder to s3 bucket. And all the logs are sent to email when the script is run through the cron job. The email output looks like this:
-----------------------Started at: Wed 3 Mar 10:56:01 +04 2021---------------------------
Start uploading to s3 bucket mohsin7007
Completed 1.8 KiB/15.5 KiB (5.2 KiB/s) with 3 file(s) remaining
upload: ../home/mohsin/Desktop/data2s3/README.md to s3://mohsin7007/README.md
Completed 1.8 KiB/15.5 KiB (5.2 KiB/s) with 2 file(s) remaining
Completed 12.9 KiB/15.5 KiB (15.0 KiB/s) with 2 file(s) remaining
upload: ../home/mohsin/Desktop/data2s3/LICENSE to s3://mohsin7007/LICENSE
Completed 12.9 KiB/15.5 KiB (15.0 KiB/s) with 1 file(s) remaining
Completed 15.5 KiB/15.5 KiB (18.0 KiB/s) with 1 file(s) remaining
------------------------Completed at: Wed 3 Mar 10:56:01 +04 2021---------------------------
I would like to bold out the "Started at" and "completed at" lines. So it will be more readable when looking for the logs from a certain date, like this:
-------------------------Started at: Wed 3 Mar 10:56:01 +04 2021---------------------------
I have used Tput utility to make these lines bold, however, the issue is when I run the script in the terminal, the outcome is as expected. However, when I open the log file or view the logs in email, The results are not bold lines. Could you guys please help me that how can I get the above-mentioned lines in bold letters I am pasting here my script as well.
#!/bin/sh
DEST=mytestingbucket8719
SOURCE=/home/sham/Desktop/data2s3
Date=`date`
bold=$(tput bold)
normal=$(tput sgr0)
echo " "
echo "$bold-----------------------Started at: $Date---------------------------$normal"
echo "Start uploading to s3 bucket" $BUCKET
aws s3 sync $SOURCE s3://$DEST
echo "complete uploading to s3 bucket" $BUCKET
echo "$bold------------------------Completed at: $Date---------------------------$normal"
echo " "