How to combined file?

hello there unix programmer

i have problem in combining file and their values..

here it is.

in my file1 i have values

1010<tab>10<tab>11<tab>13
1011<tab>11<tab>12<tab>14

in my file2 i have values

1010<tab>22<tab>23<tab>24
1011<tab>23<tab>24<tab>25

my desired output in shell scripting is
1010:10:22:11:23:13:24
1011:11:23:12:24:14:25

im hoping if could help me with my problem..
advance thank you.. and merry christmas..

I assumed that the <tab> was meant to represent tab characters, and replaced accordingly.

> cat file131
1010    10      11      13
1011    11      12      14
> cat file132
1010    22      23      24
1011    23      24      25
> cat file131 | tr "\t" ":" >file131.n
> cat file132 | tr "\t" ":" | cut -d":" -f2- >file132.n
> paste file131.n file132.n | tr "\t" ":"
1010:10:11:13:22:23:24
1011:11:12:14:23:24:25
join -o 1.1,1.2,2.2,1.3,2.3,1.4,2.4 file1 file2 | tr ' ' :

thank you so much for your responce.. but output is not like my desired output though its almost..

its like alternate.. <file1>:<file2>:<file1>:<file2> <-- values inside the file

its working.. :slight_smile:

what if sir in file1 separator is <tab> and in file2 is <column> :
is it also applicable to that function?

I don't know what you mean by <column>.

The field delimiter in both files must be the same for join to work.

You can use tr to convert one file if it is not the same as the other.

what i mean sir is..

file1
1010<tab>20<tab>34

and in other is

file2
1010:33:45

so the result is

file3
1010:20:33:34:45

something like that sir...

input:

(a.txt)
leo 1 3 5
stt 1 3 5
(b.txt)
leo 2 4 6
stt 2 4 6

output:

leo 1 2 3 4 5 6 
stt 1 2 3 4 5 6 

code:

awk '{
if(NR==FNR)
{
	split($0,arr," ")
	key[arr[1]]=$0
}
else{
	num=split($0,brr," ")
	split(key[brr[1]],crr," ")
	printf("%s ",brr[1])
	for(i=2;i<=num;i++)
		printf("%s %s ",crr,brr)
	print ""
}
}' a.txt b.txt