I have gone through various posts in this forum but could not locate where
the repeated columns are there .Hence posted this post.
File 1(colon seperated file)
Abc : 1234 : London
Def : 2456 : Paris
Efg :1456 : Newyork
Fgh : 1324 : Tokyo
Hjk : 5829 : California
Lmn : 7823 : Chicao
Klm : 6472 : Munich
Jkm : 8231 : Franfurt
Acl : 3241 : Hiroshima
Jmp : 2385 : Detroit
Lqm : 4613 : Kansas
File 2(coma seperated file)
USA , Newyork
USA , California
USA , Sanfransisco
USA , Detroit
USA , Chicago
USA , Kansas
USA , St.Louise
USA , Florida
UK , London
FRANCE , Paris
FRANCE , Marsellie.
INDIA , NewDelhi
INDIA , Mumbai
INDIA , Calcutta
INDIA , Chennai
INDIA , Bangalore
JAPAN , Tokyo
JAPAN , Nagasaki
JAPAN , Hirosima
CANADA , Ottawa
CANADA , Montreal
CANADA , Vancuvor
ARGENTINA , Buenos Aires
BRAZIL , Brassila
BRAZIL , Sao Paulo
ITALY , Rome
NORVEY , Oslo
SPAIN , Madrid
GERMANY , Frankfurt
GERMANY , Munich,
USSR , Moscow
USSR , Laningrad
USSR , Vladvostok
Output File expected as
Abc , 1234 , London ,UK
Def , 2456 , Paris , France
Efg , 3456 , Newyork , USA
Fgh , 1324 , Tokyo , Japan
Hjk , 5829 , California , USA
Lmn , 7823 , Chicago, USA
Klm , 6472 , Munich , Germany
Jkm , 8231 , Frankfurt , Germany
Acl , 3241 , Hiroshima , Japan
Jmp , 2385 , Detroit , USA
Lqm , 4613 , Kansas , USA
So far I have used join command but here it is not working as the cities are under the label countries.
Result required is Display the name of the country against the name of the city .
Tried to use
awk -F":," 'NR==FNR{ key[$1,$2]=$2;next } $1[key] { print $1,$2,$3} ' "OFS=," file2 file1 >outputfile
Thanks in advance.