Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using sed replace line in file with another file

Tags:

linux

bash

sed

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

How do I achieve:

sed 's/find/newline.txt/' infile
like image 426
FlamingGoose Avatar asked Sep 09 '16 12:09

FlamingGoose


1 Answers

With GNU sed:

Find line in file file.csv which contains find, append content (r) of file newline.txt and delete (d) line which contains find:

sed -e '/find/{r newline.txt' -e 'd}' file.csv
like image 156
Cyrus Avatar answered Sep 19 '22 02:09

Cyrus