randomx
randomx

Reputation: 15

bash script - delay between words echo command

How can I have a delay between words to simulate an actual human typing all in one horizontal line? For loops only display vertically as far as I know.

This pseudocode is what I have in mind:

    echo "hello" && sleep 1 && echo "world" && sleep 1 && echo "!"

Something like that.

Upvotes: 0

Views: 934

Answers (1)

Avishai Barnoy
Avishai Barnoy

Reputation: 113

This is actually quite a cool tool called pv standing for pipe viewer, but can simulate what you're looking for, I found the answer here.

TL;DR:

echo "You can simulate on-screen typing just like in the movies" | pv -qL 10

A little longer answer:

pv allows you to monitor data sent through a pipe, hence pipe viewer. This is done visually and therefore it has visual monitoring capabilities. In your case we use

L - this limits the character transfer rate, bytes-per-second q - quiet, otherwise you will a breakdown analysis of how long each package took to go through the pipe.

Upvotes: 1

Related Questions