Line Feed (LF)
Move the cursor down one line, scrolling if at the bottom margin.
- 0x0A
- LF
Hex: 0x0A. ASCII: ^J (Ctrl+J).
Move the cursor down one row. The column is preserved unless
linefeed mode (LNM, mode 20) is enabled, in which case
LF also performs a carriage return so the cursor
ends at column 1 of the next row.
If the cursor is on the bottom row of the
scrolling region, LF scrolls the region up by one
line. When the scrolling region spans the full screen, the scrolled-off line
is committed to scrollback. Outside the scrolling region, the cursor moves
down only when it is not already on the last row of the screen.
This sequence always unsets the pending wrap state without performing the deferred wrap.
Note
LFis the single-byte execution path for index (IND): both produce the same cursor and scroll behavior. The same dispatch is also used forVT(0x0B) andFF(0x0C).LFthen layers LNM on top.
Tip
Most modern shells and Unix tooling expect
LFalone to end a line and rely on the terminal driver (not LNM) to add the carriage return on output. Leave LNM off unless you are talking to an application that needs the legacy newline behavior.
printf "AB"
printf "\n"
printf "X"
|AB________|
|__X_______|
rows=$(tput lines)
printf "\033[${rows};1H" # move to bottom-left
printf "A"
printf "\n"
printf "X"
|A_________|
|_X________|
The previous bottom row scrolls up; the new bottom row receives the X
after the column is preserved.
printf "\033[20h" # enable LNM
printf "AB"
printf "\n"
printf "X"
printf "\033[20l" # disable LNM
|AB________|
|Xc________|