同步阅读进度,多语言翻译,过滤屏幕蓝光,评论分享,更多完整功能,更好读书体验,试试 阅读 ‧ 电子书库
I/O Redirection
cat is short for "catenate," i.e., link together. It accepts multiple filename arguments and copies them to the standard output. But let's pretend, for now, that cat and other utilities don't accept filename arguments and accept only standard input. As we said above, the shell lets you redirect standard input so that it comes from a file. The notation command < filename does this; it sets things up so that command takes standard input from a file instead of from a terminal.
For example, if you have a file called cheshire that contains some text, then cat < cheshire will print cheshire's contents out onto your terminal. sort < cheshire will sort the lines in the cheshire file and print the result on your terminal (remember: we're pretending that these utilities don't take filename arguments).
Similarly, command > filename causes the command's standard output to be redirected to the named file. The classic "canonical" example of this is date > now: the date command prints the current date and time on the standard output; the previous command saves it in a file called now.
Input and output redirectors can be combined. For example: the cp command is normally used to copy files; if for some reason it didn't exist or was broken, you could use cat in this way:
$ cat <
file1
>
file2
This would be similar to cp file1 file2.
请支持我们,让我们可以支付服务器费用。
使用微信支付打赏
