A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

January 4, 2015

Need help with script


I am using red hat enterprise linux server release 5.7

I am trying to send an email from one directory called bin.I am trying to run a shell script from that location. The output file is located in the directory named temp.

I am able to send file if it is hardcoded. But if it is having a timestamp on the end of the file. I am not able to send it.

TSTAMP ='date + %Y%m%d%H%M%S'

the syntax what i am using is mentioned below.

cat $filename | mail -s "test email" test@testemail.com

The above cat command is in if condition.

what i need is the content of the $filename should be displayed in the body of the email.

The below command works for a hard coded file for me.

echo $filename
cat /temp/filename.20150101171152 | mail -s "test email" test@testemail.com

Can you help me please
Thank You

Click Here!