Is it possible to echo a backspace in bash?
Something like
echo $'stack\b'
Shouldn't output stac
? Or I'm missing something?
More specifically, I'd like to use that in:
ls | wc -l; echo $'\b items'
you can use '\r' too. note that backspace does not clear anything - only moves the cursor back.
\b
makes the cursor move left, but it does not erase the character. Output a space if you want to erase it.
For some distributions you may also need to use -e
switch of echo
:
-e enable interpretation of backslash escapes
So it will look like
echo -e 'stack\b '
Also, files=(*) ; echo "${#files[@]} items"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With