重定向和管道操作
2007-07-30 23:45
134 查看
Redirection Operation
重定向和管道操作
All Shell
< file > file >> file
Cmd1 | cmd2
0 stdin, 1 stdout, 2 stderr
sh, ksh
0< file 1> file 2> file 1>> file 2>> file
<&m >&m m>&n, m,n is file descriptor
<&-, close standard input
>&-, close standard output
m<&- m>&-, close file descriptor m
examples:
grep “John” 0< tempfile
ls –l foo 2> error.log
cat lab1 lab2 lab3 1> cat.output 2> cat.err
cat lab1 lab2 lab3 1> cat.output.err 2>&1
pay attention to the redirection instruction order
cat lab1 lab2 lab3 2>&1 1> cat.output.err
ls –l foo 1>> output.dat 2>> error.log
ksh
set –o noclobber, set noclobber to prevent overwritting files accidently.
set +o noclobber
>| file, ignore noclobber and assign stdout to ‘file’
>>| file, ignore noclobber and append stdout to ‘file’
csh
>& file, output and error redirection
>! file, ignore noclobber and assign stdout to ‘file’
>>! file, ignore noclobber and append stdout to ‘file’,
if file does not exit, create it.
>>&! file, ignore noclobber, append stdout and stderr to ‘file’
cmd1 |& cmd2, connect stdout and stderr of cmd1 to stdin of cmd2
(cmd>/dev/tty)>&file, redirect stderr of cmd to ‘file’
set noclobber
unset noclobber
/dev/tty
/dev/null
抛弃输出数据, 如 $ echo "hello" > /dev/null
获取空文件,如 $ cat /dev/null > messages
重定向和管道操作
All Shell
< file > file >> file
Cmd1 | cmd2
0 stdin, 1 stdout, 2 stderr
sh, ksh
0< file 1> file 2> file 1>> file 2>> file
<&m >&m m>&n, m,n is file descriptor
<&-, close standard input
>&-, close standard output
m<&- m>&-, close file descriptor m
examples:
grep “John” 0< tempfile
ls –l foo 2> error.log
cat lab1 lab2 lab3 1> cat.output 2> cat.err
cat lab1 lab2 lab3 1> cat.output.err 2>&1
pay attention to the redirection instruction order
cat lab1 lab2 lab3 2>&1 1> cat.output.err
ls –l foo 1>> output.dat 2>> error.log
ksh
set –o noclobber, set noclobber to prevent overwritting files accidently.
set +o noclobber
>| file, ignore noclobber and assign stdout to ‘file’
>>| file, ignore noclobber and append stdout to ‘file’
csh
>& file, output and error redirection
>! file, ignore noclobber and assign stdout to ‘file’
>>! file, ignore noclobber and append stdout to ‘file’,
if file does not exit, create it.
>>&! file, ignore noclobber, append stdout and stderr to ‘file’
cmd1 |& cmd2, connect stdout and stderr of cmd1 to stdin of cmd2
(cmd>/dev/tty)>&file, redirect stderr of cmd to ‘file’
set noclobber
unset noclobber
/dev/tty
/dev/null
抛弃输出数据, 如 $ echo "hello" > /dev/null
获取空文件,如 $ cat /dev/null > messages
相关文章推荐
- Delphi中利用管道重定向实现对控制台(Console)程序的操作
- Linux操作之输入输出重定向和管道
- IO重定向及管道操作
- 温故而知新:查看端口占用情况以及DOS中的管道操作/重定向操作
- Shell重定向和管道操作
- dos 下重定向和管道操作
- 第三节 重定向和管道操作
- bobo说shell:shell重定向与管道操作(二)
- Shell基础:常用技巧&重定向&管道操作
- linux下的基本操作11(输入输出重定向及管道)
- linux常用命令-重定向与管道操作
- linux基本操作学习04:管理输入输出 (重定向、管道符)、vim、gedit
- shell的使用---管道与重定向
- 标准IO,管道,重定向
- Win7和Vista的安全机制对于应用程序读取配置文件相关操作的影响(虚拟重定向技术)
- linux 命令行 I/O 重定向和管道
- 进程通信之二 管道技术第一篇 输入输出的重定向
- Linux中重定向及管道(将管道“|”的功能比作逻辑“&&”的功能)
- Windows管道(Pipe)重定向stdout,stderr,stdin
- shell管道和重定向