csv file comparison with normal file

i will like to give my files as

fileB :

 
 
02.09.2011:MOU04/KUBIS--R_Lieferung_1/KUBIS_V15.0/vpn_wls_15-0-0b01
02.09.2011:MOU04/KUBIS--R_Lieferung_2/KUBIS_V15.0/apng_wls_15-0-0b02
31  02.09.2011:MOU04/KUBIS--R_Lieferung_2/KUBIS_V15.0/ecc_wls_15-0-0b02
32  02.11.2010:PPMOU/VOMS--VOMS-ASR3244/VoMS2.3.0_LieferungZu_AO-Order004385
33  02.11.2010:PPMOU/PRMKONF-RBO-01.00.13.00/XXX_mandatory_LieferungZu_AO-Order004513
33  02.11.2010:PROD/PRMKONF-RBO-01.00.13.00/XXX_mandatory_LieferungZu_AO-Order004513
34  02.11.2011:WOMS2/KUBIS--S_Lieferung_1/KUBIS_V16.0/kubis_db_16-0-0b01
02.11.2011:WOMS2/KUBIS--S_Lieferung_2/KUBIS_V16.0/kubis_db_16-0-0b02
36  02.11.2011:WOMS2/KUBIS--TS-InTime-VV/Lieferung_WoM_Maxx_VV_01_20111026
37  02.11.2011:WOMS2/PA--PA-MaxX-Konf/PA-MaxX-Konf-01.00.00.00
38  02.11.2011:WOMS2/PM--PM-5.0/PRM-LIB-05.00.00.00
39  02.11.2011:WOMS2/PM--PM-MaxX-Konf/PRMKONF-MaxX-01.00.00.00
40  02.11.2011:WOMS2/SALES--SK-Tools-2.0.0_Lieferung_01_20111024/SK-Tools-2.0/database-dist_2-0-0b01
41  02.11.2011:WOMS2/SALES--SK-Tools-2.0.0_Lieferung_01_20111024/SK-Tools-2.0/salescomponent-dist_2-0-0b01
42  02.12.2010:PPMOU/VOMS--AO-intern_RU10_VOMS_ASR3605/XXX_mandatory_LieferungZu_AO-Order004638
 

this is not a csv file or it does not contain any seperator. its just a file.

and my fileD is as follows

PRMKONF-RBO-01.00.13.00          PROD
REL_001.630.008_LieferungZu_AO-Order004266      PROD
CASS-CR099-1-2T         PPMOU
CASS-CR099-1-2T         PROD

this is a csv file . so now i want to compare this file first value of fileD ie "PRMKONF-RBO-01.00.13.00" in fileB. now if it is found in fileB whole line is copied and checked for second column of "PRMKONF-RBO-01.00.13.00" if this second column is present in that line or not. ie second column is PROD . so if this PROD is present in that line than it is not redirrected for output. if this is not present in that file then that row from fileD is redirected for output.

so output shall be

REL_001.630.008_LieferungZu_AO-Order004266      PROD
CASS-CR099-1-2T         PPMOU
CASS-CR099-1-2T         PROD

this PRMKONF-RBO-01.00.13.00 PROD is not outputed as "PRMKONF-RBO-01.00.13.00" is present and that line contains "PROD".
and also PRMKONF-RBO-01.00.13.00 can be present in many lines of fileB and each line should be considered for checking second columns of fileD.as for above example
"PRMKONF-RBO-01.00.13.00" was present in two line as

33 02.11.2010:PPMOU/PRMKONF-RBO-01.00.13.00/XXX_mandatory_LieferungZu_AO-Order004513
33 02.11.2010:PROD/PRMKONF-RBO-01.00.13.00/XXX_mandatory_LieferungZu_AO-Order004513

so PROD will be found in any of this line.

records are present in thousands..
many thanks in advance..

Please try with below script

#! /bin/bash
while read line
do
in1=`echo $line | awk '{print $1}'`
in2=`echo $line | awk '{print $2}'`
ou1=`grep $in1 fileB | grep $in2`
if [ -z "$ou1" ];then
echo $line
fi
done < fileD 

When i execute it, below is the output

Thanks,
Kalai

1 Like

thanks kalpeer . it is working...:o