在文件中使用sed替换行与另一个文件 [英] Using sed replace line in file with another file
本文介绍了在文件中使用sed替换行与另一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个很大的制表符分隔文件,我想用另一行替换该文件中的一行.由于该行具有> 100列,因此不希望使用简单的sed's/find/replace/'.我的换行符存储在文件newline.txt
I have a very large tab delimited file, I would like to replace a single line in this file with another. As the line has >100 columns, a simple sed 's/find/replace/' is not desirable. My newline is stored in file newline.txt
我如何实现:
sed 's/find/newline.txt/' infile
推荐答案
来自@Aaron
sed "s/^.*find.*$/$(cat newline.txt)/" infile.txt
find 是infile.txt中的唯一字符串,该字符串返回单行,然后将该行替换为newline.txt
Where find is a unique string in infile.txt that returns a single line, the line is then replaced by newline.txt
这篇关于在文件中使用sed替换行与另一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文