I am joining two CSV files based on 'Server_Name' column, 1st column of first file and 2nd column of second file.
If matches, output 1st and 2nd column from first file, 3rd,4th,5th,6th columns from second file.
I am expecting output CSV file as below.
Could you please send me help me with command, I am trying below command, something is not working. Please help
awk -F, 'BEGIN {FS = OFS=","} NR==FNR {h[$2] = $1; next} $1 {print h[$1],$1,$2,$3,$4,$5}' ServerInfo.csv ConfigFormat.csv > outfile.csv
File1 : ServerInfo.csv
Server_Name,Temp_Space,Temp_Space_Used,RAM_Memory,RAM_Memory_Available
LONDON,7.9G,3%,47G,25G
JAPAN,7.9G,4%,47G,28G
KENYA,7.9G,2%,47G,21G
POLAND,7.9G,4%,47G,25G
File2: ConfigFormat.csv
REGION,Server_Name,Temp_Space,Temp_Space_Used,RAM_Memory,RAM_Memory_Available
DEV,LONDON,,,,
TEST,JAPAN,,,,
PREPROD,KENYA,,,,
PROD,POLAND,,,,
Output File expected
REGION,Server_Name,Temp_Space,Temp_Space_Used,RAM_Memory,RAM_Memory_Available
DEV,LONDON,7.9G,3%,47G,25G
TEST,JAPAN,7.9G,4%,47G,28G
PREPROD,KENYA,7.9G,2%,47G,21G
PROD,POLAND,7.9G,4%,47G,25G
Thank you,
Anand