\n option in script

I have a series of around 20 files as my program output. The final line of my script gets the no of files and the file list for the present day. The no of files shoudl be printed first and the files for today must be printed in the next line. Ialso understood that echo -e must be used for with \n. However I get multiple errors for this.

Can you get me an exact syntax for the line which has \n? Please find below my script.

set -x
cd alt/mystudies
a=`ls -ltr | wc -l`
echo $a
Today=`date '+%Y%m%d'`
echo $Today
b=`ls P* | grep $Today`
echo $b
echo -e The no of files for United dated `date` is $a and the files are below \n $b | mailx -s " United files " venkidhadha@yahoo.com
m

Put double quotes around your echo output, and drop the space after the \n:

echo -e "The no of files for United dated `date` is $a and the files are below \n$b"...

Thanks that really worked well. small syntax making a large diff :slight_smile:

---------- Post updated at 01:53 AM ---------- Previous update was at 01:52 AM ----------

Also can you let me know what do i use for tab characters?

Hi.

-e covers that too, just use \t for tabs.

The echo on Linux really is poor. It isn't Posix standard (i.e. probably not portable).

You should use print or printf instead of echo.

Hello,

had to get back to this echo -e after a long time. I am using the general discussed below.

however my output has the -e options in it. Not sure of the reason.

cut -f6 -d '/' newfile.csv >> /piccare/incoming/United/import/newfiles.csv
(echo -e "The total files in the directory is \t $c \n The files for today is \t $d";uuencode newfiles.csv newfiles.csv) | mailx -s " test " venkita.ve