To remove the newline character while appending into a file

Hi All,

We append the output of a file's size in a file. But a newline character is appended after the variable.
Pls help how to clear this.

filesize=`ls -l test.txt | awk `{print $5}'`
echo File size of test.txt is $filesize bytes >> logfile.txt

The output we got is,
File size of test.txt is 1024
bytes.

Expected output:
File size of test.txt is 1024 bytes

Thanks,
Amio

#!/bin/ksh

filesize=`ls -l test.txt | awk '{print $5}'`
echo File size of test.txt is $filesize bytes >> logfile.txt

Hi vgersh99,
Sorry, it is just what u have written. I mistakenly put `.

The output of
filesize=`ls -l test.txt | awk '{print $5}'`
echo File size of test.txt is $filesize bytes >> logfile.txt

is,

File size of test.txt is 1024
bytes

Pls help..
thanks,
Amio

Amio,

Try this:

filesize=`ls -l filename | awk '{print $5}' | tr -d [:space:]`

works just fine on Solaris.
add 'set -x' to the script and debug it from there.