M HYPE SPLASH
// news

Clear a line in the terminal

By John Campbell

I sometimes start writing a command in the terminal (iTerm2) which half-way written I want to erase.

How can quickly remove all the characters on the line being worked on in the terminal?

1 Answer

Press Ctrl-C. This will essentially start a new line.

To clear everything before the cursor position, use Ctrl-U.

To clear everything after the cursor position, use Ctrl-K.

These are some of the basic Bash keyboard shortcuts.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy