Display from a variable using echo.

I have a variable that is outputting a lot of space.

here has been 45 lines returned ...

how can I remove the spaces between the "been and the 45"
CODE:

fil_len=`wc -l < coshb.txt`
if [ ${fil_len} -gt 21 ]; then
cat coshb.txt | more
echo " "
echo "There has been ${fil_len} lines returned ..."

I am using a ksh in Solaris.

Thank in advance
:wink:

Go to a command prompt and actually type in the command wc -l coshb.txt and you'll understand why..

You could substitute this:

fil_len=`wc -l < coshb.txt | awk '{print $1}'`

One way...
echo "There has been" ${fil_len} "lines returned ..."

Cool!!!!

Now can you explain what the was wrong with my previous line and how the new line is doing what I actually want?????

fil_len=`wc -l < coshb.txt | awk '{print $1}'`

Thanks for the quick response.

:slight_smile:

Wow.. mine looks at the output of the command and, using spaces as a field delimiter, prints the first (and in this case, only) field, the number of lines in your file. But it calls the awk utility.. really I think Perderabo's is faster - it uses the fact that if you echo a variable without enclosing it in quotes, all spaces are stripped from the variable before being output to the screen..