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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:11:59+00:00 2026-06-13T12:11:59+00:00

I have two files, and I need to compare the second field from File1

  • 0

I have two files, and I need to compare the second field from File1 and the first field from File2.
If there is a match to print the second field of File2 and the entire line matched from File1
If there is no match to print “NOT FOUND” and the entire Line from File1

File1

\\FILESERV04\PCO;S:\CA\USII ECOM;/FS7_434D/FILESERV04/BUSII;;;;\\FILESERV04\PCO\;467,390,611 Bytes;11,225 ;157 
\\FILESERV12\MINE$;S:\CA\Naka;/FS3_434D/FILESERV12/NAKA;;;;\\FILESERV12\MINE$\;0 Bytes;0 ;0 
\\FILESERV12\INTEG$;S:\CA\PLOTA;/FS3_434D/FILESERV12/INTEG;;;;\\FILESERV12\INTEG$\;231,094,432,158 Bytes;175,180 ;21,309 
\\FILESERV15\ED$;S:\CA\ED;/FS3_434D/FILESERV12/ED;;;;\\FILESERV15\ED$\;244,594,432,158 Bytes;145,040 ;21,311

File2

S:\CA\USII ECOM;782
S:\CA\PLOTA;0
S:\CA\Naka;781

Desired output:

782;\\FILESERV04\PCO;S:\CA\USII ECOM;/FS7_434D/FILESERV04/BUSII;;;;\\FILESERV04\PCO\;467,390,611 Bytes;11,225 ;157 
781;\\FILESERV12\MINE$;S:\CA\Naka;/FS3_434D/FILESERV12/NAKA;;;;\\FILESERV12\MINE$\;0 Bytes;0 ;0 
0;\\FILESERV12\INTEG$;S:\CA\PLOTA;/FS3_434D/FILESERV12/INTEG;;;;\\FILESERV12\INTEG$\;231,094,432,158 Bytes;175,180 ;21,309 
NOT FOUND;\\FILESERV15\ED$;S:\CA\ED;/FS3_434D/FILESERV12/ED;;;;\\FILESERV15\ED$\;244,594,432,158 Bytes;145,040 ;21,311

If the field number to compare is the same field number on both files this line works:

awk -F";" 'NR==FNR{a[$1]=$2;next}{if (a[$1])print a[$1]";"$0;else print "Not Found"";" $0;}' File1 File2

But is not working here because in this case I have different field number to compare from both files.

Thanks

  • 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-06-13T12:12:00+00:00Added an answer on June 13, 2026 at 12:12 pm
     awk -F";" 'NR==FNR{a[$1]=$2;next}{if ($2 in a)print a[$2]";"$0;else print "Not Found"";" $0;}'  File2 File1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two binary files with different sizes. I need to compare first N
I have two directories with the same list of files. I need to compare
I have two CSV files (three columns) which I need to compare and extract
Say that I have two CSV files (file1 and file2) with contents as shown
I need to compare two XML files with wildcard characters in those. I have
I need to compare strings from two text files. While separating the strings using
I have two text files which contain the below numbers File1 00000 11111 File2
I have a problem. I have two sqlite files and I need (with PHP)
I have two files: public interface PrintService { void print(PrintDetails details); class PrintDetails {
I have two files which both contain a list of words. Is there an

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.