开发者

String replacement with a 'batch file' ran with sh?

I've been told I c开发者_JS百科an concatenate files in a sort of batch file by using sh.

e.g.

cat file1 file2 >> file3

cat file1 file4 >> file5

Is it possible to do a string replacement, I mean load file, replace x with y and run the file with sh.


The 'sed' utility, the stream editor, is the shell tool to do this. You could do something like the following to do what you asked, join file1 and file2, change all occurances of x to y and then run the commands with the bash shell:

cat file1 file2 | sed -e 's/x/y/g' | bash
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜