循环并追加/写入同一个文件而不会覆盖 [英] Loop and append/write to the same file without overwriting

查看:182
本文介绍了循环并追加/写入同一个文件而不会覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

for num in {1..5}
do
perl simulate.pl file.txt file2.txt > output.txt
done

但是我的输出每次都被覆盖.我知道他们应该是对此不知所措的简单答案.

But my output is overwritten every time. I know their should be some kind of a simple answer to this which I don't know.

推荐答案

使用>>将内容合并到文件中. >每次写入文件时都会覆盖该文件.

Use >> to concat the contents into a file. > will overwrite the file every time you write into it.

这篇关于循环并追加/写入同一个文件而不会覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆