Merge multi-line output into a single line

Hello

I did do a search and the past threads doesn't really solve my issue. (using various awk commands)

I need to combine the output from java -version into 1 line, but I am having difficulties.

When you exec java -version, you get:

java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)

But I need to make it look like

java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)

Any ideas?

Thanks for the help!

# java -version | sed -n ":a; $ s/\n//gp; N; b a"
java version "1.4.2"gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-46)Copyright (C) 2006 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(sed code is from someone else, but I can't find the post...)

Or:

java -version | xargs

thanks guys for your replies.

I tried both and they still show on 3 lines...could it be something with putty thats causing the issue? or something with the terminal environment settings?

It could be your version is printing to stderr. Try adding 2>&1 to the end of either command (assuming you're on ksh or similar).

thanks...actually i took care of this problem by capturing the output into a perl script and then use s/\n//g to remove the new lines and now they are all same line...

thanks though to you both for your assistance.