Output to be in single line

Hi All,

Small script but :wall:, please help in this regard.

for i in 1 2 3
do
echo $i
done

result :

1
2
3

I want the above to be printed as below
expected result:

1 2 3

Thanks in advance :slight_smile:

?

echo 1 2 3
for i in 1 2 3; do echo -n "$i "; done

"printf" is more portable than "echo -n". I was told that this command is on almost every *nix system unlike "-n" option for echo.

for i in 1 2 3
do
  printf "%d " "$i"
done