When you run grep
, if you include a filename (grep pattern file
), it searches that file. When you don't, it searches the standard input (stdin). If you include it in a pipe (foo | grep
), it reads from the pipe. When you run just grep pattern
, it reads input from the console. This is a very common pattern among Unix and Linux utilities. When you type exit
, end
, quit
, or anything else, it compares it with the pattern and prints it if it matches, just as if you had given it a file. Try entering a line that matches the pattern - you'll see it echoed back to you.
To get out of this, hit Ctrl+D to signal the end of the file. Ctrl+C will kill most programs, but it's less clean than Ctrl+D.