用sed -i参数列表替换所有文件太长[关闭]

问题描述 投票:1回答:1

我想用sed -i替换所有文件。我想用newstring替换word oldstring

root-:
sed -i "s| oldstring | newstring |g" *    

参数列表太长

我在同一个目录中有很多文件。我想替换所有文件字符串。

我怎么解决这个问题?

linux sed linux-kernel gnu
1个回答
0
投票

要在没有命令行太长的情况下生成所需数量的命令行,请使用find

find . -maxdepth 1 -type f -exec sed -i "s| oldstring | newstring |g" {} +
© www.soinside.com 2019 - 2024. All rights reserved.