如何将写在文件上的任何内容重定向到Linux中的另一个文件?

Suppose we have two files, a.txt and b.txt . If we write anything in a.txt & b.txt, it should be redirected to c.txt.

假设我们有两个文件 ,a.txt和b.txt。 如果我们在a.txt和b.txt中写入任何内容,则应将其重定向到c.txt。

tee may help for this purpose.

tee可能会为此目的提供帮助。

tee: duplicate standard input

T型:标准输入重复

You may try a command like this:

您可以尝试这样的命令

echo "hello" | tee -a a.txt >>b.txt

Both a.txt and b.txt will contain the “hello”.

a.txt和b.txt都将包含“ hello”。

Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。


No , but it should be redirected to c.txt
The data of both a.txt and b.txt should be redirected to third text file.
As i am giving input to a & b , it should be redirected to c.txt simultaneaously.

否,但应将其重定向到c.txt
a.txt和b.txt的数据都应重定向到第三个文本文件。
当我给a和b输入时,应同时将其重定向到c.txt。



The method above shows redirecting output a.txt -> b.txt.

上面的方法显示了重定向输出a.txt -> b.txt

Are what you need “a -> c and b -> c” or “a -> b -> c“.

您需要的是“ a -> cb -> c ”或“ a -> b -> c ”。

Both case can be derived from the above command with the similar idea.

两种情况都可以从上述命令以相似的想法派生出来。

翻译自: https://www.systutorials.com/how-to-redirect-anything-written-on-a-file-to-another-file-in-linux/

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值