merging two files

Friends,
os: redhat enterprise linux/SCO UNIX5.0

I have two files and I would like to merge on given key value.

Now I have tried with join commd but it does not supporte multiple delimiters.
and if records length is not fixed.

join -a1 5 -a2 1 -t[;,] -o file1 file2 > outname

Can any one give details if join supports strings base join uitlity.
Thanks in advance friends.

You have some typo's in the posted files, assuming the files look like:

and you have spaces after the comma's and around the colons:

awk -F ' |,' '
NR==FNR{a[$1]=$NF;next}
$NF in a{print $NF" "$1" "$7" "$5" "a[$NF]" "$1}' file2 file1

For the second solution, just change the order of the fields in the print command.

Regards

Shouldn't the the -F option be?

awk -F ' :,'  ........
-F ' |,' 

specifies two different field separators, a space or a comma while

 -F ' :,'

specifies one field separator of 3 characters. So the answer is no.

Regards

Dear Franklin52
Omg thanks lot for your prompt reply and precise script.Sorry for
the typo excuse me for that .Just for my knowledge would you please explain the point .

Secondly does join command support two field seperator ?? If yes the
what is the syntex ??
Only to know .Have great weekend.

Cheers .

base name:

sed -e 's/,/:/g' -e 's/ //g' b > b.t
sed 's/ //g' a> a.t
nawk 'BEGIN{FS=":"}
{
if(NR==FNR)
	name[$5]=sprintf("%s %s %s",$4,$3,$1)
else
{
	if(name[$1]!="")
		final[$1]=sprintf("%s %s",name[$1],$4)
}
}
END{
for(i in final)
	print i" "final
}' a.t b.t
rm a.t b.t

An explanation of the code:

awk -F ' |,'

Specify 2 field separators, a spacer or a comma.

NR==FNR is true if you read the first file (file2).

{a[$1]=$NF;next}

Create an array a with the first field as index and assign the value of the last field to the array. Read the next line of file2.

$NF in a{print $NF" "$1" "$7" "$5" "a[$NF]" "$1}

This line affects file1, if the last field is an existing index of array a print the given fields.

A passage from the manpage:

Regards

Dear Franklin52 ,
Thanks once again you have just shown the road ,on executing your code
though it did not give me the required output, I have made alteration in the
script, it is after not yeilding the result.
awk -F ' |:, ' ' at the begining and gave me the correct result.

This is I am writing for sharing the knowledge and may be due to different version of Linux .But surely your explanation has gave me the inner sight of how array can be used.

Dear Summer_cherry , thanks lot dear , but your script did not gave me any output at all.

Thanks very much once againg .

I am using Redhat Enterprise Linux-nash 4.4 .