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'
\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"
.