bash - 修改几个特定文件中的某些内容,例如 txt (bash)
问题描述
我想在几个文件中写一些东西,我尝试了 find :
find . -name "*.txt" |
但我不知道在管道之后我能写什么。
我还尝试了“for”:
for element in *
do
if [[ $element = '*.txt' ]]
then
echo "cc" > $element
fi
done
但我的如果是错的,
如果有人可以帮助我
解决方案
只需使用带有.txt
后缀 in的 glob 模式for
:
for i in *.txt; do
# if there are no matching files, break
[ -f "$i" ] || break
echo "cc" > "$i"
done
推荐阅读
- excel - 枚举 Power-Query 中的文本值
- machine-learning - 递归神经网络是强化学习还是监督学习模型?
- python - python 在尝试获取 tkinter 条目值时出错
- anylogic - 使用 pyCommunicator 的模型缺少 Python 文件
- python - 使用线程等待类变量更改
- sql - 如何进行一对多查询?
- amazon-web-services - 登录 AWS 实例时权限被拒绝(公钥)
- spring - 如何从 Spring Cloud 客户端服务器使用 Spring Cloud 配置服务器 Jdbc 后端配置?
- javascript - JavaScript 将 CSS 应用于图像并保存
- python - 在 model.fit() 中使用图像生成器作为 y 参数