Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I have two files, file1 and file2. file2 is reference file and file1 is getting generated by sql script on fly. I need to check either all entries in file2 is present in file1 or not. If not, i need to print those entries from file2. common entries should not be there in the output file.
both the files are csv files.file structures:
file1 looks like as below:
ORDER_IMPORT_HPIPE
ORDER_IMPORT_MHRWEB
SO_MODULE
MHE_PICKCNFM_INP
WORK_ORDER_RECPT_PROCESS
ORDER_IMPORT_ECOMMERCEfile2 looks like as below:
SO_MODULE
-
WORK_ORDER_ALLOC_PROCESS
SFA_ORDERS
CUSTOMER_IMPORT_PROCESS
WORK_ORDER_RECPT_PROCESS
ORDER_IMPORT_ECOMMERCE
output file should beWORK_ORDER_ALLOC_PROCESS
SFA_ORDERS
CUSTOMER_IMPORT_PROCESSkalyan

Brute force method. Let me know if you have any questions:
#!/bin/kshwhile read myline
do
cnt=0
while read line
do
if [[ "$myline" = "$line" ]]
then
((cnt+=1))
break
fi
done < file1
if [[ $cnt -eq 0 ]]
then
echo "$myline" >> output.file
fi
done < file2

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |