in a Bash script I need to execute a command.
I also need to catch its output to let the script send it to me via e-mail.
In the e-mail I want to print the entire output of the command, and I wish to highlight the error strings, preserving the order of the messages in the same order the command prints out.
For example, if the command prints out the following output:
180321 15:52:02 command: message 1
180321 15:52:03 command: message 2
180321 15:52:04 command: error 1
180321 15:52:05 command: error 2
180321 15:52:06 command: message 3
180321 15:52:07 command: message 4
180321 15:52:08 command: error 3
I want to receive an e-mail with a specific subject (which tells me that we had an error) and with this body:
180321 15:52:02 command: message 1
180321 15:52:03 command: message 2
180321 15:52:04 command: error 1
180321 15:52:05 command: error 2
180321 15:52:06 command: message 3
180321 15:52:07 command: message 4
180321 15:52:08 command: error 3
Could you help me to find out how I could make this?
Thank you!