How to remove a newline character at the end of filename

Hi All,
I have named a file with current date,time and year as follows:

month=`date | awk '{print $2}'`
date=`date | awk '{print $3}'`
year=`date | awk '{print $6}'`
time=`date +%Hh_%Mm_%Ss'`
filename="test_"$month"_"$date"_"$year"_"$time".txt"
> $filename

The file is created with a newline character at the end (after .txt) of the filename. Am not getting why this is happening.. Can u help me??

Thanks,
Amio

Amio,

Not sure why you are using awk with date command. You can as well use date command as shown below.

month=`date '+%b'`
day=`date '+%d'`
year=`date '+%Y'`
time=`date '+%H%M%S'`

Use man date for more options.

Then, try to execute your script. You should have no newline characters.

HTH, :cool:

Regards,

Praveen

Hi Praveen,
Thanks for ur reply.. It worked..
Many thanks..