0

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 "       " 
  • The log file is a **text** file. How on earth could you expect bold or italics to see in a plain text file? Perhaps you would have to convert the output to some format like PDF or HTML. – user1934428 Mar 04 '21 at 09:42
  • Probably HTML would be the easiest to achieve..... – user1934428 Mar 04 '21 at 09:49
  • :) sorry for my less knowledge about scripting, coding, programming :) :) I am very new in this domain. However, thanks for the clarification. – jarral rajput Mar 04 '21 at 11:15
  • This is not a programming problem. A file is a sequence of bytes, which represent text, i.e. a sequence of letters, in a certain encoding (for instance UTF8). Letters are entities like 'x', 'U' or `た`, but there is no special character code for a bold version of these characters. – user1934428 Mar 04 '21 at 11:31

0 Answers0