输出重定向
命令输出重定向的语法为:
command > file 或 command >> file
这样,输出到显示器的内容就可以被重定向到文件。果不希望文件内容被覆盖,可以使用 >> 追加到文件末尾
[[email protected] ~]# who root tty1 2015-09-03 16:21 root pts/3 2015-09-03 19:09 (192.168.11.1) [[email protected] ~]# who > output.txt [[email protected] ~]# cat output.txt root tty1 2015-09-03 16:21 root pts/3 2015-09-03 19:09 (192.168.11.1)
输入重定向(<可省略)
command < file
[[email protected] ~]# wc -l output.txt 2 output.txt [[email protected] ~]# wc -l < output.txt 2
[[email protected] ~]# grep tty output.txt root tty1 2015-09-03 16:21 [[email protected] ~]# grep tty < output.txt root tty1 2015-09-03 16:21
时间: 2024-08-05 02:17:05