Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6096257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:54:22+00:00 2026-05-23T12:54:22+00:00

I just wanna to substract one CSV-File from another one, but not if the

  • 0

I just wanna to substract one CSV-File from another one, but not if the lines are the same. Instead of comparing the lines I’d like to look if the lines matching in one field.

e.g. the first file

EMAIL;NAME;SALUTATION;ID
foo@bar.com;Foo;Mr;1
bar@foo.com;Bar;Ms;2

and the second file

EMAIL;NAME
foo@bar.com;Foo

the resultfile should be

EMAIL;NAME;SALUTATION;ID
bar@foo.com;Bar;Ms;2

I think u know what I mean 😉

How is that possible in bash? It’s easy for me doing this in Java, but I realy like to learn how to do that in bash. Also I can substract by comparing the lines using sort

#! / bin / bash    
echo "Substracting Files..."

sort "/tmp/list1.csv" "/tmp/list2.csv" "/tmp/list2.csv" | uniq -u >> /tmp/subList.csv

echo "Files successfully substracted."

But the lines arn’t the same tuple. So I have to compare line with keys.

Any suggestions? Thanks a lot.. Nils

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:54:23+00:00Added an answer on May 23, 2026 at 12:54 pm

    One possible solution coming to my mind is this one (working with bash):

    grep -v -f <(cut -d ";" -f1 /tmp/list2.csv) /tmp/list1.csv
    

    That means:
    cut -d ";" -f1 /tmp/list2.csv: Extract the first column of the second file.
    grep -f some_file: Use a file as pattern source.
    <(some_command): This is a process substitution. It executes the command and feeds the output to a named pipe which then can be used as file input to grep -f.
    grep -v: Print only the lines not matching the pattern(s).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wanna to delete from specified text file first N characters, but i'm
I followed this instruction but not worked for me. I just wanna install and
I just wanna know if it is possible to pause a playing SWF file
I just wanna do the basics... give the shaders information from my application. I
I'm searching for an one-liner for mailing within jsp. I just wanna send the
I just wanna display the contents of files from sdcard on emulator (as image
I just wanna ask this very trivial question, I do not know if this
I just wanna grab with a regex the name from this text: Name: Paul
i'm sorry if there is a question like this i just wanna know, i'm
Its the same thing right? Or is there a slight difference? I just wanna

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.