问题
Learning command line as basis for further web development learning. Using a Mac whenever I try to use GREP or CAT, Terminal hangs up. Once I enter the process it displays in the top border, but nothing happens. What am I doing wrong?
回答1:
If you just type
$ cat
at the command line, the shell will wait for further input, because you haven't given it any input to work on.
cat
will take its input and send it to wherever you're sending its output. By default, this is to stdout: the terminal. So you can start with something like this:
/Users/jpk/:510 $ cat
dog boy van
dog boy van
foo bar baz
foo bar baz
^D
/Users/jpk/:511 $
When I type cat
and hit return, the shell waits until some input comes in, and then it redirects that to the output. This goes on until I send an end-of-file signal (^D)
I'm not sure what you're seeing for grep
- when I just type a bare grep
and hit enter, I get usage notes:
/Users/jpk/:512 $ grep
usage: grep [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]
/Users/jpk/:513 $
来源:https://stackoverflow.com/questions/27283339/grep-and-cat-cause-terminal-to-hangup-terminal-displays-process-going-but-nothi