| #!/bin/bash |
| # Echos a string with a delay between each character |
| # When a # character is encountered, it's replaced with a 1 second pause |
| # and the # is NOT echoed out |
| # |
| # When there are no params: |
| # - take stdin as the string |
| # Where there is 1 param: |
| # - take the contents of the file in param 1 as the string |
| |
| # Decide where to get the string |
| if [ $# -eq 0 ] |
| then |
| str=`cat` |
| else |
| str=`cat $1` |
| fi |
| |
| # Break the string into characters and echo them 1 at a time |
| while [ -n "$str" ] |
| do |
| # if [[ "${str:0:1}" = *$'\x0a'* ]] |
| # then |
| # printf "%c" "$str" |
| # sleep 2 |
| # elif [[ "${str:0:1}" = *$'#'* ]] |
| if [[ "${str:0:1}" = *$'#'* ]] |
| then |
| sleep 1 |
| else |
| printf "%c" "$str" |
| sleep 0.05 |
| fi |
| str=${str#?} |
| done |
| printf "\n" |
| |