Skip to main content
ansicode

C0 controls — BS, HT, LF, CR, BEL (single-byte codes)

The single-byte C0 control characters that move the cursor or signal events — no ESC introducer needed.

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x08 BS \x09 HT \x0a LF \x0d CR \x07 BEL
\\033[\010 / \011 / \012 / \015 / \007
\\e[\b / \t / \n / \r / \a
ESC [BS / HT / LF / CR / BEL
hex08 / 09 / 0a / 0d / 07

Description

These five single-byte controls predate ANSI/VT and are still acted on by every terminal: **BS** (0x08, `\b`) moves the cursor one cell left (does NOT erase — pair with a space + BS again to erase, or use EL). **HT** (0x09, `\t`) advances the cursor to the next tab stop (default every 8 columns). **LF** (0x0a, `\n`) moves down one line (and, with `onlcr` tty mode, returns to column 1 — Unix shells rely on this, which is why a raw `\n` looks ladder-stepped under `stty -onlcr`). **CR** (0x0d, `\r`) returns to column 1 of the current line — used for progress bars (`\r` + redraw). **BEL** (0x07, `\a`) rings the audible bell or flashes the visual bell depending on the terminal's setting; it also serves as the de-facto OSC string terminator (see OSC 0/2 and OSC 8). None of these consume an `ESC` byte — they are part of the C0 control set inherited from ASCII (1963) / ECMA-6.

Spec citation: ECMA-48 §8.2 (C0 set) / ASCII / ECMA-6

Parameters

BS (0x08)backspace — cursor left 1
HT (0x09)horizontal tab — to next tab stop
LF (0x0a)line feed — down 1 line
CR (0x0d)carriage return — to column 1
BEL (0x07)bell — audible/visual alert; OSC terminator

Examples

bash
printf '\rprogress: 50%%\r'   # CR redraws current line\nprintf 'beep\a\n'           # BEL rings the bell
python
import sys, time\nfor i in range(101):\n  sys.stdout.write(f'\r{i}%'); sys.stdout.flush(); time.sleep(0.02)
go
fmt.Print("\rprogress: 50%\r")
javascript
process.stdout.write('\rprogress: 50%\r')
c
printf("\rprogress: 50%%\r");

Terminal support

xterm
yes
Linux console (fbcon)
yes
macOS Terminal.app
yes
iTerm2
yes
Windows Terminal
yes
cmd.exe / ConPTY
yes
kitty
yes
alacritty
yes
WezTerm
yes
Ghostty
yes
GNOME Terminal
yes
Konsole
yes
tmux
no
GNU screen
no

Related sequences