Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continue output on same line

Tags:

bash

People also ask

How do I print a loop output on the same line?

Modify print() method to print on the same line The print method takes an extra parameter end=” “ to keep the pointer on the same line. The end parameter can take certain values such as a space or some sign in the double quotes to separate the elements printed in the same line.

How do you print two statements on the same line?

To print multiple expressions to the same line, you can end the print statement in Python 2 with a comma ( , ). You can set the end argument to a whitespace character string to print to the same line in Python 3. With Python 3, you do have the added flexibility of changing the end argument to print on the same line.

How do you print two outputs on the same line in Python?

To print on the same line in Python, add a second argument, end=' ', to the print() function call. print("It's me.")

How do I keep text on the same line in Python?

If you want to print your text on the same line in Python 2, you should use a comma at the end of your print statement. Here's an example of this in action: print "Hello there!", print "It is a great day."


Use the -n option to skip printing newline at the end. More reference at echo docs.

So you could do something like this:

echo -n "$0: Starting backup process in '$backupdir'... " 

use the more portable printf:

printf "%s" "$0: Starting backup process in '$backupdir'... "
sleep 3
printf '[OK]\n'

echo -n hello