Merging files based on the contents

Hi,
I have a file f1 having the contents as below
select (<condn>) from dual
I have another file f2 having the contents as below
1,
2,
3
I want to replace <condn> in f1 with the contents of f2
I tried using sed like this
sed "s:<condn>:`cat f2`:g" f1
The above command resulted in sed: function S:<condn>:1, cannot be parsed"
Then I tried
sed "s:<condn>:`cat f2| tr -d "\n"`:g" f1
Now it gives the o/p as
select (1,2,3) from dual
However I want the o/p in the below format:
select (1,
2,
3) from dual
How to get this?/
Please help

for the last part:

echo "select (1,2,3) from dual" | sed 's/,/,\n/g'

May be inefficient solution, but it works for your input. :stuck_out_tongue:

$cat f1
select (<condn>) from dual

$cat f2
1,
2,
3
# Writing select ( and  ) from dual  delimited by new line and writing to a file called  t
$sed '
s/\(.*\)<condn>\(.*\)/\1\n\2/w t' f1

$sed '/select/r f2' t
select (
1,
2,
3
) from dual

With awk:

awk 'NR==FNR{s=s?s"\n"$0:$0;next}{$2="("s")"}1' f2 f1

Regards