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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:25:28+00:00 2026-05-27T13:25:28+00:00

I need to process two file contents. I was wondering if we can pull

  • 0

I need to process two file contents. I was wondering if we can pull it off using a single nawk statement.

File A contents:

AAAAAAAAAAAA  1
BBBBBBBBBBBB  2
CCCCCCCCCCCC  3

File B contents:

XXXXXXXXXXX  3
YYYYYYYYYYY  2
ZZZZZZZZZZZ  1

I would like to compare if $2 (2nd field ) in file A is the reverse of $2 in file B.
I was wondering how to write rules in nawk for multi-file processing ?
How would we distinguish A’s $2 from B’s $2

EDIT: I need to compare $2 of A’s first line (which is 1) with the $2 of B’s last line (which is 1 again) .Then compare $2 of line 2 in A with $2 in NR-1 th line of B. And so on…..

  • 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-27T13:25:29+00:00Added an answer on May 27, 2026 at 1:25 pm

    You can do something like this –

    [jaypal:~/Temp] cat f1
    AAAAAAAAAAAA  1
    BBBBBBBBBBBB  2
    CCCCCCCCCCCC  3
    DDDDDDDDDDDD  4
    
    [jaypal:~/Temp] cat f2
    AAAAAAAAAAA  5
    XXXXXXXXXXX  3
    YYYYYYYYYYY  2
    ZZZZZZZZZZZ  1
    

    Solution:

    awk '
    NR==FNR {a[i++]=$2; next}
    {print (a[--i] == $2 ? "Match " $2 FS a[i] : "Do not match " $2 FS a[i])}' FileB FileA
    Match 1 1
    Match 2 2
    Match 3 3
    Do not match 4 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to stream-process using perl a 1Gb text file encoded in UTF-16 little-endian
I have the need to open up a single file in two different instances
I need to process a large file, around 400K lines and 200 M. But
Using C++ (and Qt), I need to process a big amount of 3D coordinates.
I have a parent process that forks two children. I need to force a
I need to have two processes share information through a memory mapped file. One
I need to split am XML file (~400 MB) in two, so that a
I need to read (scan) a file sequentially and process its content. File size
I need to process a HTML content and replace the IMG SRC value with
I need to process the incoming predefined ASN format data(coming from verity of clients

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.