I'm learning to use the command line in Ubuntu and I've just learned about grep. Unfortunately, I input grep and the word I was searching for, but accidentally hit the enter key before entering the directory to search, which started a new line without results, of course. I hit every key on the keyboard out of frustration but I don't see a way out of the command to start over and type it out properly. Ultimately, I open a new Bash tab or close it and reopen the program entirely to start over. Is there a way to escape grep without doing that?

1 Answer 1


Since grep did not have a file to read from, it was reading from the keyboard (standard input or stdin in that context).

You could interrupt with Ctrl+C or simulate the end of the file with Ctrl+D on an empty line (right after enter).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .