Tag: Typewriter

The trick here is simple, first we disable the newline printed by echo command with the \”-n\” option and then we enable the interpretation of the backslash characters with the \”-e\” option. As the \”\\r\” is used as carriage return which brings you to the start of the line without the newline (like in typewriter), we will use the same to get the desired effect. So, if you wanted a stopwatch for a 100 seconds on the console then this simple bash for loop would do the same:

1234567

for i in `seq 100 1`

do

echo -ne \"$i\\r\"

done

Have fun playing with this and comment if you find some other interesting use of the same.