04_03_Linux
来源:互联网 发布:playmemories mac版 编辑:程序博客网 时间:2024/05/18 21:42
管道和重定向
运算器,控制器:CPU
存储设备:ram
输入输出设备:
程序:
系统设定:
默认输出设备:标准输出 1
默认输入设备:标准输入 0
标准错误输出:STDERR 2
I/O设备重定向
linux:
输出重定向:> (原有内容会被覆盖) ;>>(追加输出)
[root@localhost /]# ls /var > /tmp/var.out[root@localhost /]# cat /tmp/var.out accountcachecrashdbempty
[root@localhost /]# ls /etcc > /tmp/errtest.outls: cannot access /etcc: No such file or directory
[root@localhost /]# ls /etcc 2> /tmp/errtest.out[root@localhost /]# cat !$cat /tmp/errtest.outls: cannot access /etcc: No such file or directory
[root@localhost /]# cat << END> the first line.> the second line.> ENDthe first line.the second line.
重定向所有的输出:&>
输入重定向:<
[root@localhost /]# catsdfg^C[root@localhost /]# cat < /tmp/errtest.out ls: cannot access /etcc: No such file or directory
[root@localhost /]# tr 'a-z' 'A-Z'ASFDdsfASFDDSF
[root@localhost /]# tr 'a-z' 'A-Z' < /tmp/errtest.outLS: CANNOT ACCESS /ETCC: NO SUCH FILE OR DIRECTORY
[root@localhost /]# cat << END> the first line.> the second line.> ENDthe 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.outhello world.[root@localhost /]# cat tmp/hello.out hello world.
[root@localhost /]# wc -l /etc/passwd41 /etc/passwd[root@localhost /]# wc -l /etc/passwd | cut -d' ' -f141
0 0
- 04_03_Linux
- 13_03_Linux进程管理之一
- 04
- 04
- 04
- 04
- 2007-04-04
- 开篇-2009-04-04
- 04/04/09
- 2010-04-04
- 10-04-04SD
- 2014-04-04
- 2014-04-04
- PROJECT 04-04
- 2016-04-04
- 216-04-04
- 2014-04-04
- 2005.10.04
- 一些常见异常及解决办法(持续更新)
- 【11.13】57のTest
- struts2面试题
- 软考总结之范式及心得总结
- PHP命名空间(Namespace)的使用详解
- 04_03_Linux
- auto_ptr智能指针
- Java爬虫(3)——拼接url抓取“加载更多”内容
- 软考上午题中的计算题
- C++版本直接插入排序
- 19个方便渗透测试的Chrome扩展
- Bootstrap中的栅格栅格系统
- Hadoop性能调优
- 《Android和PHP开发最佳实践》学习笔记一:采用Eclipse开发,Apache服务器默认地址修改