How to print the words in the same line with space or to the predefined line?

HI,

cat test

abc

echo "def" >> test

output is

cat test

abc
def

the needed output is

cat test

abc def

and so on

thanks in advance

cat > test << END
abc def

some more text
END

---------- Post updated at 01:15 PM ---------- Previous update was at 01:10 PM ----------

Sorry, seems I misunderstood the problem.

In that case, you need to edit your line with utilities like, sed,ed,awk, etc

with awk command

awk '{ORS=" "}1' test

replace
echo "def" >> test
by
echo -n " def" >> test
Don't forget the space !

"-n" suppress the trailing newline i guess..

Excellent !!!:slight_smile: