linux重定向
来源:互联网 发布:java线程死锁是什么 编辑:程序博客网 时间:2024/06/03 10:03
#显示当前目录文件 test.sh test1.sh test1.sh实际不存在
[chengmo@centos5 shell]$
ls
test
.sh test1.sh
ls
: test1.sh: 没有这个文件和目录
test
.sh
#正确输出与错误输出都显示在屏幕了,现在需要把正确输出写入suc.txt
# 1>可以省略,不写,默认所至标准输出
[chengmo@centos5 shell]$
ls
test
.sh test1.sh 1>suc.txt
ls
: test1.sh: 没有这个文件和目录
[chengmo@centos5 shell]$
cat
suc.txt
test
.sh
#把错误输出,不输出到屏幕,输出到err.txt
[chengmo@centos5 shell]$
ls
test
.sh test1.sh 1>suc.txt 2>err.txt
[chengmo@centos5 shell]$
cat
suc.txt err.txt
test
.sh
ls
: test1.sh: 没有这个文件和目录
#继续追加把输出写入suc.txt err.txt “>>”追加操作符
[chengmo@centos5 shell]$
ls
test
.sh test1.sh 1>>suc.txt 2>>err.txt
#将错误输出信息关闭掉
[chengmo@centos5 shell]$
ls
test
.sh test1.sh 2>&-
test
.sh
[chengmo@centos5 shell]$
ls
test
.sh test1.sh 2>
/dev/null
test
.sh
#&[n] 代表是已经存在的文件描述符,&1 代表输出 &2代表错误输出 &-代表关闭与它绑定的描述符
#/dev/null 这个设备,是linux 中黑洞设备,什么信息只要输出给这个设备,都会给吃掉
#关闭所有输出
[chengmo@centos5 shell]$
ls
test
.sh test1.sh 1>&- 2>&-
#关闭 1 ,2 文件描述符
[chengmo@centos5 shell]$
ls
test
.sh test1.sh 2>
/dev/null
1>
/dev/null
#将1,2 输出转发给/dev/null设备
[chengmo@centos5 shell]$
ls
test
.sh test1.sh >
/dev/null
2>&1
#将错误输出2 绑定给 正确输出 1,然后将 正确输出 发送给 /dev/null设备 这种常用
<p>[chengmo@centos5 shell]$
ls
test
.sh test1.sh &>
/dev/null
#& 代表标准输出 ,错误输出 将所有标准输出与错误输出 输入到/dev/null文件
<
/p
>
- [Linux]Linux重定向
- Linux重定向详解
- linux 重定向命令
- Linux重定向详解
- Linux输入输出重定向
- linux 重定向
- linux重定向
- Linux重定向
- Linux重定向详解
- Linux输出重定向
- linux 重定向命令
- Linux重定向详解
- Linux重定向
- linux 命令重定向
- linux重定向命令
- Linux重定向
- Linux输入输出重定向
- linux Shell重定向
- HDU 4308 BFS
- 题目1475:IP数据包解析
- 查询表结构
- vs2010出现devenv.exe占用100%CPU解决办法
- PostgreSQL学习手册(常用数据类型)
- linux重定向
- ganglia学习小记
- signal(SIGPIPE, SIG_IGN)
- oracle rowid存贮类型
- 杭电1003 maxsum--解题报告
- git同步远程分支
- HTTP请求与响应(转载)
- 正则表达式
- 使用HttpClinet保持session一致