views:

56

answers:

1

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?

A: 

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)

picknick