Backspace (BS)
Move the cursor one column to the left without erasing the cell.
- 0x08
- BS
Hex: 0x08. ASCII: ^H (Ctrl+H).
Move the cursor one column to the left. BS does not erase the cell
underneath the cursor; the cursor simply moves. To both move back and erase,
applications typically send BS SP BS.
This sequence always unsets the pending wrap state. If the cursor was past
the right edge in pending-wrap state, BS moves it back into the screen
without performing the deferred wrap.
If the cursor is already at the leftmost column (or at the
left margin when left/right margin mode is enabled),
BS is a no-op by default.
This is equivalent to cursor backward (CUB) with
Pn = 1, with the same wrap behavior derived from the active modes.
Note
When reverse wrap (DECRAW, mode 45) or extended reverse wrap is enabled together with autowrap,
BSat the left edge can wrap the cursor up to the end of the previous row. This is mode-dependent and disabled by default.
printf "ABC"
printf "\b"
printf "X"
|ABX_______|
printf "\033[1;1H" # move to top-left
printf "\b"
printf "X"
|Xc________|
cols=$(tput cols)
printf "\033[${cols}G" # move to last column
printf "A" # set pending wrap state
printf "\b"
printf "X"
|_________X|