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 1019653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:02:52+00:00 2026-05-16T11:02:52+00:00

I have 2 text files to compare on their first column. The following comm

  • 0

I have 2 text files to compare on their first column. The following comm command shows the common lines from the 2 files correctly.

comm develop1.txt qa1.txt -12

But the following diff command does not show the difference as expected.

diff develop1.txt qa1.txt --side-by-side

Expected output is as follows:

mysql-data/webservice 280292 | mysql-data/webservice 28684

But these two values are not on the same line because the number in the last column are different. I do actually need to compare the numbers in side-by-side format.
How can it be achieved?

  • 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-16T11:02:53+00:00Added an answer on May 16, 2026 at 11:02 am

    If you’re up for something quick and dirty (not something I’d release into production but certainly okay for my own purposes):

    for key in $(cat develop1.txt qa1.txt | awk '{print $1}' | sort -u) ; do
        devval=$(grep "^${key} " develop1.txt | awk '{print $2}')
        qa1val=$(grep "^${key} " qa1.txt | awk '{print $2}')
        if [[ "${devval}" != "${qa1val}" ]] ; then
            echo "$key: dev=[${devval}], qa=[${qa1val}]"
        fi
    done
    

    The first line retrieves all the unique keys from both files into a list (won’t work if your keys have spaces but that’s likely to make any solution harder to implement, and it doesn’t appear to be the case here).

    The second and third lines simply get the values for each key from the two files.

    The if statement then prints out the key and the two values but only where the values are different.

    Not pretty, not even thoroughly tested, but it may be adequate for your purposes. You do have to watch out for edge cases, like the possibility a key might exist multiple times in a file, or where the key may not be at the start of a line.

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

Sidebar

Related Questions

I'm looking for a diff/compare tool that shows differing lines from two text files,
Suppose I have two text files. The first one, called reference.txt has the following
I have 498 text files resulting from WebScraping results from a form on a
I have many text files, their total size is about 300GB ~ 400GB. They
I'm trying to have python read some lines of text from a file and
I have 4 text files in one folder and a pattern.txt to compare these
I have text files containing structured data (it is a proprietary format and not
In a project we have text files looking like this: mv A, R3 mv
I have multiple text files with logged data like this: 6/23/09 17:00 0.443 6/23/09
I have two text files that contain columnar data of the variety position -

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.