开发者

Merge two files using cygwin tools

I have one tab separated file (file1.txt) with two columns and one file (file2.txt) with a long string of text. I want to replace specific characters in file2 with the column values in file1.

An example:

file1.txt

text1 text11
text2 text22
text3 text33

file2.txt

开发者_开发知识库
I want to insert text here:$1 and the other text here: $2

The desired result:

I want to insert text here:text1 and the other text here: text11
I want to insert text here:text2 and the other text here: text22
I want to insert text here:text3 and the other text here: text33

How do I accomplish this with cygwin tools?


Okay, I figured out how to do this with sed.

sed 's/([^\t]) (.)/I want insert text here:\1 and the other text here: \2/g'

note that I didn't have the text in a file (file2.txt)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜