Reputation: 1731
Consider the following script to stop and start tomcat:
#!/bin/bash
# Shutdown tomcat and delete all the logs
echo --- Shutting down Tomcat...
sh /opt/tomcat/bin/shutdown.sh -force &> /dev/null
rm -f /opt/tomcat/logs/* &> /dev/null
echo OK
# Startup tomcat
sh /opt/tomcat/bin/startup.sh &> /dev/null
echo --- Starting up Tomcat...
until [ "`curl --silent --show-error --connect-timeout 1 -I http://localhost:8080 | grep 'Coyote'`" != "" ];
do
sleep 10
done
echo OK
What I'd like to be able to do is show the OK on the same line as the message stating what's going on. How can I achieve this?
Upvotes: 2
Views: 2513
Reputation: 753970
echo -n "--- Shutting down Tomcat..."
...
echo OK
The -n
suppresses the newline at the end of the echo. Note that if the Tomcat server emits any information, it will start after the triple dot.
As pointed out in the comments, you should consider:
printf "--- Shutting down Tomcat..."
...
printf "OK\n"
(Although you could leave the second as echo OK
, it seems better to be consistent.)
Upvotes: 6