clrtoeol - Linux
Overview
clrtoeol is a text manipulation utility that clears all characters from the current cursor position to the end of the line. It is commonly used for interactive text editing in terminals and command-line interfaces.
Syntax
clrtoeol [-e] [-u] [--]
Options/Flags
- -e: Erase to the end of the screen.
- -u: Erase to the beginning of the line (default behavior).
Examples
Simple Example:
Clear from the cursor position to the end of the current line:
clrtoeol
Erase to End of Screen:
Clear all text from the cursor position to the bottom of the terminal:
clrtoeol -e
Erase to Beginning of Line:
Clear from the cursor position to the start of the current line:
clrtoeol -u
Common Issues
No Output:
Ensure that the terminal supports ANSI escape sequences.
Integration
With grep
:
Combine clrtoeol with grep
to quickly clear matching lines from a text file:
grep -v pattern | clrtoeol
With Shell Prompt:
Add clrtoeol to the shell prompt to automatically clear the current line after each command:
PS1="\u@\h \w \[\033[K\]\n\$ "
Related Commands
- tput: Control terminal settings.
- printf: Format and display text.
- clear: Clear the entire terminal screen.