while loop to add text to the end of a file

Hi all,

I've got 2 files.

File 1 has a list say
a
b
c
d
e
f

File 2 got
start=

What I want is to create File 3 which look like this
start=a,b,c,d,e,f

So is it possible to loop throught File1 to echo it into File3 in one line?

Thanks

awk 'NR==FNR||FNR==1{printf $0;next}{printf ",%s",$0}' File2 File1 > File3
1 Like

bash, and ksh93 can do this:

var="$(<file1)"
echo "$(<file2)${var//$'\n'/,}" > file3

Perfect thanks