Outputting on Same Line?

April 28, 2016 at 10:43:10
Specs: CentOS
Can I take this command:

echo "HIT";lsscsi |grep -c HIT

And make the output (on one line):

HIT = 30

Instead of on two lines:

HIT
30

How do I then make a return to start a new line to do things like:
echo test; lsscsi |grep -c HI; echo test 2; lsscsi |grep -c TO

to become

test = 5
test 2 = 6

Thanks.

I reply as fast as I can, but it could be hours or months.

message edited by CPU13


See More: Outputting on Same Line?

Report •

#1
April 29, 2016 at 04:50:35
I am sorry, but what? What of putting them on the same line with "=" as I described?

I reply as fast as I can, but it could be hours or months.


Report •

#2
April 29, 2016 at 09:34:08
Instead of using the echo command, use the printf command:

printf "HIT = "

Unlike echo, printf does not automatically print a new-line unless you tell it:

printf "HIT = \n"

It's similar to the "C" language version of printf. check out the MAN page for printf.

message edited by nails


Report •
Related Solutions


Ask Question