读入数据:input
输出数据:outputcentos
打开的文件都有一个fd:file descriptor 文件描述符
Linux给程序提供三种I/O设备bash
[root@centos7 proc]# echo $$ 2199 [root@centos7 proc]# ll /proc/$$/fd 总用量 0 lrwx------. 1 root root 64 10月 19 20:09 0 -> /dev/pts/0 lrwx------. 1 root root 64 10月 19 20:09 1 -> /dev/pts/0 lrwx------. 1 root root 64 10月 19 20:09 2 -> /dev/pts/0 lrwx------. 1 root root 64 10月 19 20:22 255 -> /dev/pts/0 [root@centos7 proc]#
[root@centos7 proc]# ll /proc/self/fd 总用量 0 lrwx------. 1 root root 64 10月 19 20:25 0 -> /dev/pts/0 lrwx------. 1 root root 64 10月 19 20:25 1 -> /dev/pts/0 lrwx------. 1 root root 64 10月 19 20:25 2 -> /dev/pts/0 lr-x------. 1 root root 64 10月 19 20:25 3 -> /proc/2222/fd
格式:命令 操做符号 文件名ide
支持的操做符号
1> or >:重定向标准输出
2>:重定向标准错误centos7
[root@centos7 ~]# xxx 2> /data/f1.log [root@centos7 ~]# cat /data/f1.log -bash: xxx: 未找到命令
[root@centos7 ~]# rm /data/f1.log 2> /data/all.log y [root@centos7 ~]# cat /data/all.log rm:是否删除普通文件 "/data/f1.log"?[root@centos7 ~]#
&>:同时重定向标准输出和错误code
[root@centos7 ~]# ls /data/ /rr &> /data/all.log [root@centos7 ~]# cat /data/all.log ls: 没法访问/rr: 没有那个文件或目录 /data/: all.log
以上若是文件已经存在,文件内容会被覆盖
set -c 禁止将内容覆盖已有文件,但可追加;强制覆盖 &|
set +c容许覆盖ip
<input
[root@centos7 ~]# cat bc.log 2+3 [root@centos7 ~]# bc < bc.log 5 [root@centos7 ~]# seq -s+ 1 10 > bc.log [root@centos7 ~]# bc < bc.log 55