如何根据另一个文件中的值替换文件中的字符串? (内部示例) [英] how to replace strings in file based on values from another file? (example inside)

查看:82
本文介绍了如何根据另一个文件中的值替换文件中的字符串? (内部示例)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何根据另一个文件中的值替换文件中的字符串.

how to replace strings in file, based on values from another file.

示例2个文件-输入,输出

Example, 2 files - input, output

输入:

12345 1

输出:

(1,'a lot of text', 'some other info',0,null, 12345),
(2,'a lot of text', 'some other info',0,null, 12345),
(3,'a lot of text', 'some other info',0,null, 12345),
(4,'a lot of text', 'some other info',0,null, 12345),
(5,'a lot of text', 'some other info',0,null, 12345);

需要完成的事情:

从文件输入"中读取值,并在文件输出"中将所有"12345"替换为"1". 感谢您的提前帮助

read values from file 'input', and replace all '12345' with '1' in file 'output'. Thanks for help in advance

推荐答案

怎么样:

sed `sed 's|\(.*\) \(.*\)|s/\1/\2/|' input` output

这篇关于如何根据另一个文件中的值替换文件中的字符串? (内部示例)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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