shell脚本将文本追加到每个文件? [英] Shell script to append text to each file?

查看:470
本文介绍了shell脚本将文本追加到每个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个完整的文本文件的文件夹。我需要的文字相同的块附加到他们每个人(当​​然覆盖原文件)。

I have a folder full of text files. I need to append the same block of text to each of them (and of course overwrite the original file).

我想知道正确的Bash shell语法会是什么这一点。我会用猫吗?

I was wondering what the correct Bash shell syntax would be for this. Would I use cat?

我已经做了一些批处理脚本,但我不是一个专家猛砸。任何建议AP preciated。

I have done a few batch scripts but I'm not a Bash expert. Any suggestions appreciated.

推荐答案

使用追加重定向。

for f in *.txt
do
  cat footer >> "$f"
done

这篇关于shell脚本将文本追加到每个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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