Grep and cat cause Terminal to hangup. Terminal displays process going but nothing happens [closed]

眉间皱痕 提交于 2019-12-20 07:48:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!