Echo print in different lines within email sent by Cron job

Hi all,

I think this could have a simple solution, just I can�t get it so far.
I have the script below that includes several echo commands in order
to show that every part of the script have been executed. A cron job
executes this script and when is completed the output is sent by email.

#!/usr/bin/sh

echo "+++++++++++++++++++++++++++++++++++++++++++++"
echo "+++++++++++++  PROCESS PART 1   +++++++++++++"
echo "+++++++++++++++++++++++++++++++++++++++++++++"

FILE1=$(ls)
for each in $FILE1
do echo "Processing $each...\n";
done

echo "+++++++++++++++++++++++++++++++++++++++++++++"
echo "+++++++++++++  PROCESS PART 2   +++++++++++++"
echo "+++++++++++++++++++++++++++++++++++++++++++++"

FILE2=$(ls *.txt)
for each in $FILE2
do echo "Processing $each...\n";
done

echo "+++++++++++++++++++++++++++++++++++++++++++++"
echo "+++++++++++++++   WORK DONE  ++++++++++++++++"
echo "+++++++++++++++++++++++++++++++++++++++++++++"

I only want to receive the output sent by the Cron job
correctly formatted(each echo print in different line)
as shown below:

+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++  PROCESS PART 1   +++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++
Processing filename1.txt
Processing filename2.txt
Processing filename3.txt
+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++  PROCESS PART 2   +++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++
Processing filename4.txt
.
.
.
Processing filenameN.txt
+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++   WORK DONE  ++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++

I`ve tested adding \n at the end of every echo command but doesn`t seem to work.
The current output I get in the email received is continuos echo prints like this:

+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++  PROCESS PART 1   +++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++
Processing filename1.txt...\n Processing filename2.txt...\n Processing filename3.txt...\n 
+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++  PROCESS PART 2   +++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++
Processing filename4.txt...\n ....Processing filenameN.txt...\n 
+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++   WORK DONE  ++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++

May somebody help me saying how can I get the echo prints in different line?

Thanks in advance for your help.

Try adding the -e switch to the echo command

do echo -e "Processing $each...\n";

Hi toro95037, thanks for your reply.

It works adding -e option, the only thing is that it adds like a doble spacing like an
empty line, something like

this is my firts echo print...

this is my second echo print..

and not as I supposed.

this is my firts echo print...
this is my second echo print..

But in general terms is what I looking for.

Thanks again for your help:b:

This is a feature of outlook - it's assuming any two lines that follow each other are part of the same paragraph so it joins them up. Best solution is to put a couple of spaces in the front of each line, this causes outlook to display them correctly.

eg:

echo "  Processing $each...\n";

Hey Chubler_XL, how did you know that?:stuck_out_tongue:

It was exactly how you said.:smiley:

Really thanks, the echo print outs are now in different lines and closer between each other.:b: