How to remove tab space if any in a variable?

I have a variable sumOfJEOutputFile which is the output file of an SQL command which contains the output of that SQL. The output looks like below:

-----------
          58

I am using following code to manipulate the output:

(sed 1,2d $sumOfJEOutputFile > $newTemp1 | sed '$d' $newTemp1) > $newTemp2
count=$(cat $newTemp2)
thresholdValue=40000
if [[ $count -le $thresholdValue ]]; then
echo "JE count for today is less than 40000" | mailx -s "The JE count for- `date` is $count " "akanksha.kumari@abc.com"
echo "success"
else
echo "JE count for today is more than 40000" | mailx -s "The JE count for- `date` is $count " "akanksha.kumari@abc.com"
echo "More JE"
fi

Mail which I am getting has the subject as below:

The JE count for- Thu Jul  3 04:46:34 EDT 2014 is           58  

I want to remove the space which is coming before 58 so that the subject looks like:

The JE count for- Thu Jul  3 04:46:34 EDT 2014 is 58  

How can I achieve this?

Change the count variable

count=$(cat $newTemp2 | tr -s "\t" " ")
1 Like

Do we have space between every thing?

yes

Thank you!! It works for me now

1 Like