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

  • Home
  • SEARCH
  • 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 8968177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:24:41+00:00 2026-06-15T17:24:41+00:00

I have a text file (FILE_A.txt) with this content: Content1 Content2 Content3 And other

  • 0

I have a text file (FILE_A.txt) with this content:

Content1
Content2
Content3

And other text file (FILE_B.txt) with this content:

A[#]
B[#]
C[#]

I would like to combine FILE_A.txt and FILE_B.txt in other file (FILE_C.txt) in this way:

A[Content1]
B[Content2]
C[Content3]

How could I make this using bash shell in linux (sed, cut, grep, etc)?

  • 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-15T17:24:42+00:00Added an answer on June 15, 2026 at 5:24 pm

    Here we go.

    # awk 'NR==FNR{a[NR]=$0;next;} sub(/#/,a[FNR])' FILE_A.txt FILE_B.txt
    A[Content1]
    B[Content2]
    C[Content3]
    

    How does this work?

    • NR==FNR – causes the following statements to be run if the record number matches the FILE record number – that is, we are currently reading only the firs tfile.
    • {a[NR]=$0;next;} – Store values from the first file in an array.
    • sub(/#/,a[FNR]) – Once we’re in the second file, substitute # for the matching value stored from the first file. Note that this isn’t inside curly brackets, so it’s being evaluated as a condition. If the sub() statement succeeds, the current line is printed.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .txt file having some text. I want to read this file
I have a file (called print_1012720.txt ) that looks like the text shown below.
I have a text file test.txt with the following content: text1 text2 And I
I have this small script that sorts the content of a text file #
I have this test.txt file with the following content: @echo off wget -q http://subs.ro/get/21518
I have this function which writes content to a text file: function write($text){ fwrite($this->fp,
I have a plain text file with this content: Test: \u0410\u0412\u0422\u041e I try to
I have a text file : ban.txt have content a:5:{i:14528;s:15: 118.71.102.176;i:6048;s:15: 113.22.109.137;i:16731;s:3: 118.71.102.76;i:2269;s:12: 1.52.251.63;i:9050;s:14:123.21.100.174;}
I have a text file with some content. I need to search this content
I have text file with content as: 12345678901222344567 Then I used this code to

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.