Unix output connectors on the same line

I created this script and I want to print the outputs on one line, how to do it? This is my script

#!/bin/bash echo "enter start and stop numbers" read start stop while [ $start -lt $stop ] do echo $start start=`expr $start + 1` done 
+4
source share
2 answers

Using printf or echo -n . Also, try using start=$(($start + 1)) or start=$[$start + 1] instead of back ticks to increase this variable.

 #!/bin/bash echo "enter start and stop numbers" read start stop while [ $start -lt $stop ] do printf "%d " $start start=$(($start + 1)) done 

 #!/bin/bash echo "enter start and stop numbers" read start stop while [ $start -lt $stop ] do echo -n "$start " # Space will ensure output has one space between them start=$[$start + 1] done 
+3
source

Using

 echo -n $start 

Check out: http://ss64.com/bash/echo.html

+1
source

Source: https://habr.com/ru/post/1391997/


All Articles