CSV Comparison

I want to compare file2.csv against file1.csv and write differences in file3.csv with line no.
I tried below command but it only giving me the data on console and not in file3,also line no is not giving.

Can someone please help me

awk -F',' 'NR==FNR {a[$1]=$0;next;}; !($1 in a) ll ($0 != a[$1]);' file1 file2

@Ashwini1 , welcome to the forum, we hope you find it instructive and friendly.

firstly, a couple of requests/questions

  • is this homework/coursework (which is fine if it is but you need to let the team know that)

  • which operating system are you working with (a linux distro is assumed, but clarification appreciated)

  • you mention file1, file2, file3 but no example of actual data is provided for file1,file2 , please provide before any response can be given

  • file3 is mentioned but is nowhere to be seen in the code snippet supplied, so it obviously needs inclusion somewhere. Additionally, provide a sample of what you expect the output to look like - matching it with the sample data you will provide from file1 and file2

  • once you've responded to ALL the enquiries above we can move on.

  • make use of the markup tags when posting code, it should be in triple quotes to distinguish from text

look forwards to hearing back from you

  1. I am working on one of office project but new to the shell scripting.

  2. I am working on windows and scripting under impala shell

  3. File1 and File2 will be the CSV files with huge data extracted from different db tables

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.