When I type "grep doc" in the terminal, it just don't do anything, stopping the terminal from doing anything else before I escape using Ctrl+C or Z.
I know this isn't how I'm supposed to use grep, but just curious why this is happening.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communitygrep
by default searches standard input if no files are given:
grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus (-) is given as file name) for lines containing a match to the given PATTERN. By default, grep prints the matching lines.
If you just do grep doc
grep expects standard input to come and search inside it (don't enter parts between <
and >
into the terminal, these are comments):
$ grep doc
a b c <PRESS ENTER HERE>
doc <NO MATCH WAS FOUND IN PREVIOUS LINE, TYPE doc AND PRESS ENTER AGAIN>
doc <MATCH WAS FOUND>
grep '([a-z]+[0-9]*.x){2,3}'
and type a bunch of sample lines on your keyboard to make sure it matches what you think it does. Lines that match will be echoed, lines that don't will not.
Mar 27, 2015 at 6:10
somecommand | grep foo
grep
is waiting for input.
From man grep
:
[...]
DESCRIPTION
grep searches the named input FILEs (or standard input if no files are named
[...]