04_03_Linux
2016-11-13 21:20
246 查看
管道和重定向
运算器,控制器:CPU
存储设备:ram
输入输出设备:
程序:
系统设定:
默认输出设备:标准输出 1
默认输入设备:标准输入 0
标准错误输出:STDERR 2
I/O设备重定向
linux:
输出重定向:> (原有内容会被覆盖) ;>>(追加输出)
错误信息是没有重定向的
重定向错误输出:2>
重定向所有的输出:&>
输入重定向:<
此处文档:<<
set -C:禁止对已经存在的文件进行覆盖(如果要覆盖使用>|)
set +C:关闭上面功能
管道
前一个命令的输出,作为后一个命令的输入
命令1 | 命令2 | 命令3
把echo的输出,作为tr的输入
tee:及输出到标准输出有保存文件
只显示一个文件的行数:
运算器,控制器:CPU
存储设备:ram
输入输出设备:
程序:
系统设定:
默认输出设备:标准输出 1
默认输入设备:标准输入 0
标准错误输出:STDERR 2
I/O设备重定向
linux:
输出重定向:> (原有内容会被覆盖) ;>>(追加输出)
[root@localhost /]# ls /var > /tmp/var.out [root@localhost /]# cat /tmp/var.out account cache crash db empty
错误信息是没有重定向的
[root@localhost /]# ls /etcc > /tmp/errtest.out ls: cannot access /etcc: No such file or directory
重定向错误输出:2>
[root@localhost /]# ls /etcc 2> /tmp/errtest.out [root@localhost /]# cat !$ cat /tmp/errtest.out ls: cannot access /etcc: No such file or directory
[root@localhost /]# cat << END > the first line. > the second line. > END the first line. the second line.
重定向所有的输出:&>
输入重定向:<
[root@localhost /]# cat sdfg^C [root@localhost /]# cat < /tmp/errtest.out ls: cannot access /etcc: No such file or directory
[root@localhost /]# tr 'a-z' 'A-Z' ASFDdsf ASFDDSF
[root@localhost /]# tr 'a-z' 'A-Z' < /tmp/errtest.out LS: CANNOT ACCESS /ETCC: NO SUCH FILE OR DIRECTORY
此处文档:<<
[root@localhost /]# cat << END > the first line. > the second line. > END the first line. the second line.
[root@localhost /]# cat >> /tmp/test.out <<EOF > the first line. > the second line. > EOF [root@localhost /]# cat /tmp/test.out the first line. the second line.
set -C:禁止对已经存在的文件进行覆盖(如果要覆盖使用>|)
set +C:关闭上面功能
管道
前一个命令的输出,作为后一个命令的输入
命令1 | 命令2 | 命令3
把echo的输出,作为tr的输入
[root@localhost /]# echo "hello,world" | tr 'a-z' 'A-Z' HELLO,WORLD
tee:及输出到标准输出有保存文件
[root@localhost /]# echo "hello world." | tee /tmp/hello.out hello world. [root@localhost /]# cat tmp/hello.out hello world.
只显示一个文件的行数:
[root@localhost /]# wc -l /etc/passwd 41 /etc/passwd [root@localhost /]# wc -l /etc/passwd | cut -d' ' -f1 41
相关文章推荐
- 03_04_Linux
- [鸟哥linux视频教程整理]04_03_Linux 管理及IO重定向
- 视频: 千重浪Linux系统调试技术培训 03-04_Basic_GCC_and_EXT
- 第三课 第四讲03_04_Linux用户及权限详解
- [鸟哥linux视频教程整理]03_04_Linux用户及权限详解
- 03_04 Linux用户及权限详解(上)
- 03.配置putty连接Linux系统,并实现中英文输入输出;配置vnc服务器
- Linux基础知识--(04)使用虚拟机安装CentOS 5.3
- 2009-04-03技术学习:wicket框架中DatePicker使用
- Linux_shell_文件安全与权限(04)
- chap04 Linux用户管理
- 剖析Linux系统启动过程 - chenchao03的专栏 - CSDNBlog
- ASP.NET Repeater_第五篇_分页03-04
- 04/03/09
- 10-03-04 把握
- Linux_shell_文件安全与权限(03)
- Linux文件查找命令find,xargs详述04
- Java语言介绍(04)开源项目(03)作业调度(01)Quartz
- Ubuntu/Linux入门介绍(04)-Ubuntu系统目录结构
- linux启动时挂载rootfs的几种方式 - chenchao03的专栏 - CSDNBlog