Join same line from multiple file

Hi,

Can we use shell script to combine multiple file ?
For example we have 3 file

1.txt

2.txt

3.txt

and the result should be :

With awk:

awk '{
  getline f2 < "2.txt"
  getline f3 < "3.txt"
  print $0,f2,f3
}' OFS="," 1.txt

Regards

Wow..
great.. thanks Franklin

Hi Franklin
So if we have file :

then should i dump first to temp file :

and then running that script..

You can get the output with one awk command:

$ cat file
number=111
char: aaa,xxx
name-1ab
number=222
char: bbb,xxx
name-2ab
number=333
char: ccc,xxx
name-3ab
$
$
$ awk -F" |,|-|=" '
/number/{s=$2}
/char/{s=s","$2}
/name/{s=s","$2;print s}
' file
111,aaa,1ab
222,bbb,2ab
333,ccc,3ab
$
$

Regards

paste -d , 1.txt 2.txt 3.txt

Great .. thanks all :wink:

regards,
Bow