Dear all,
Every day I create a mynumbers.csv file which including numbers, for example:
09976543
09976542
09976541
some days it's empty.
I want a script to print the csv file only if it has numbers inside and send it to my mail.
So I built a little script that will print the csv file only if it's more than 0 bytes:
Code:
a=$/my_destination/mynumbers.csv
if [ -s $a ]; then
echo My files: &&cat $a
fi
the thing is that I want to implement it inside my mail command without creating a txt file. I want something like that:
Code:
echo (print the csv file according the if statement) | mail -s "mine" myemail@gmail.com
I know I can make it like that:
Code:
echo my files: $a | mail -s "mine" myemail@gmail.com
but then when the file is empty (it has one empty line) it prints that one empty line and thenit makes one line space which I don't want and makes me crazy.
I thought I could some how take the if command and make it as a variable, but I didn't manage, and I didn't find anywhere that it's possible. maybe someone has another suggestion?