7、Linux 标准输入输出操作全解析

Linux 标准输入输出操作全解析

1. 输出重定向问题及解决方法

在 Linux 系统中,我们经常会遇到输出重定向的需求,但有时简单的 > 重定向并不能如我们所愿地将所有输出保存到文件中。

1.1 问题描述

当我们使用 gcc 编译一个有错误的文件时,例如 bad.c

$ gcc bad.c
bad.c: In function `main':
bad.c:3: error: `bad' undeclared (first use in this function)
bad.c:3: error: (Each undeclared identifier is reported only once
bad.c:3: error: for each function it appears in.)
bad.c:3: error: parse error before "c"

如果我们尝试使用 > 重定向将输出保存到 save.it 文件中:

$ gcc bad.c > save.it
bad.c: In function `main':
bad.c:3: error: `bad' undeclared (first use in this function)
bad.c:3: error: (Each undeclar
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值