Compartilhe e aproveite:
#!/bin/bash
TYPEDSTRING=""
COVERSTRING="hello world"
POS=0
while IFS= read -r -n 1 -s X
do
if [ "$X" == "" ]
then
break
fi
if [ "$X" == $'\x7F' ]
then
echo -n -e '\b \b'
if [ "$POS" != "0" ]
then
POS=$(( (POS-1) ))
TYPEDSTRING="${TYPEDSTRING:0:POS}"
fi
else
echo -n "${COVERSTRING:POS:1}"
TYPEDSTRING="${TYPEDSTRING}$X"
POS=$(( (POS+1) ))
fi
done
echo
echo "'$TYPEDSTRING'"