从stdin 读入 输出到stdout
来源:互联网 发布:为mysql设置密码 编辑:程序博客网 时间:2024/06/05 11:56
#define BUFFSIZE 1024
int main ()
{
char buf[BUFFSIZE];
int n;
while( (n = read(STDIN_FILENO,buf,BUFFSIZE) ) >0 )
{
if (write(STDOUT_FILENO,buf,n) != n)
err_sys("write error");
}
if(n < 0)
err_sys("read error");
exit(0);
}
运行结果:
<bldc:/home/tingbinz/apue.2e/include/1>R*_*G:./1_2
hello
hello
word
word
world
world
^C<bldc:/home/tingbinz/apue.2e/include/1>R*_*G:./1_2
hello
hello
world
world
eof
eof
EOF
EOF
^Z[1] + Stopped (SIGTSTP) ./1_2
<bldc:/home/tingbinz/apue.2e/include/1>R*_*G:./1_2
HELLO
HELLO
WORLD
WORLD
<bldc:/home/tingbinz/apue.2e/include/1>R*_*G: ^[
<bldc:/home/tingbinz/apue.2e/include/1>R*_*G:
<bldc:/home/tingbinz/apue.2e/include/1>R*_*G:ps -ef | grep 1_2
tingbinz 18890 8507 0 02:31:54 pts/285 0:00 ./1_2
tingbinz 24402 8507 0 02:32:59 pts/285 0:00 grep 1_2
<bldc:/home/tingbinz/apue.2e/include/1>R*_*G:fg 1_2
ksh: 1_2: Arguments must be %job or process ids
<bldc:/home/tingbinz/apue.2e/include/1>R*_*G:fg 18890
./1_2
hello
hello
^C<bldc:/home/tingbinz/apue.2e/include/1>R*_*G:
- 从stdin 读入 输出到stdout
- stdin, stdout, stderr 从定向
- 用标准IO(带缓冲的IO)实现从stdin复制到stdout
- stdin,stdout,stderr,生定向到文件
- Linux重定向输出,输入,错误 stdin stdout stderr
- stdout stdin python里面的标准输出和输入
- c stdout输出到文件
- 如何将stdin、stdout、stderr重定向到/dev/null
- fflush(stdin) fflush(stdout)
- stdin stdout 说明
- fflush(stdout); fflush(stdin);
- stdin,stdout,stderr
- stderr,stdin,stdout
- stdin,stderr,stdout
- stdin,stderr,stdout
- stdin,stdout,stderr转载
- stdin,stdout,stderr详解
- stdin、stdout、stderr
- 关于EditText中的TextWatcher监听
- 华为华三交换机堆叠配置
- C++ STRING 和WSTRING 之间的互相转换函数
- context:annotation-config
- 注释驱动的 Spring cache 缓存介绍
- 从stdin 读入 输出到stdout
- 阿里巴巴接口时间(Date)类型字段提交格式
- 第一次只出现一次的字符
- 每天进步一点点
- shell 脚本中 1>、2>、2>&1 的作用
- GCD应用
- Dos常用命令
- 打印沙漏
- MyEclipse下配置mysql驱动的方法