6

Is there any way I could run several echo statements one after the other with a delay?

For example:

The first statement will be:

echo Hello1

after 1/2 second, run the Second echo statement:

echo Hello2

Likewise, is it possible to run several statements one after the other with a time delay without printing all echoes at once?

3 Answers 3

7

Perhaps you would like to use sleep <number of seconds> Like sleep 60 to wait for a minute.

eg. run from commandline

$ echo 'hello1'; sleep 2; echo 'hello2'

or in a bash script file (myscript.sh)

#!/bin/bash
echo 'hello1'
sleep 2
echo 'hello2 after 2 seconds'
sleep 2
echo 'hello3 after 2 seconds'
Sign up to request clarification or add additional context in comments.

Comments

1
echo Hello1
usleep 500000 # sleep 500,000 microseconds
echo Hello2

The usleep(1) command is part of the initscripts package on Fedora.

Comments

1
for i in `echo "hello1 hello2 hello3"`; do echo $i; sleep 2; done

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.