开发者

Call sed in linux

开发者 https://www.devze.com 2023-02-04 13:02 出处:网络
I need to replace some string into another in files. I know how to do that with single file: sed -i \'s/a/b/\'. But what about recursive function? I think I have to开发者_开发知识库 use find . -name *

I need to replace some string into another in files. I know how to do that with single file: sed -i 's/a/b/'. But what about recursive function? I think I have to开发者_开发知识库 use find . -name * with xargs somehow.

I need your help :)


You are correct, find and xargs are what you want to use. Here's an example which will find all files with the ".ext" file extension in the current folder and all subfolders ,and replace the letter a with the letter b in the files.

find . -name "*.ext" | xargs sed -i 's/a/b/g'
0

精彩评论

暂无评论...
验证码 换一张
取 消