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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:00:45+00:00 2026-06-08T02:00:45+00:00

Ok, this question is two-fold: 1) The actual file manupulation bit 2) Looping this

  • 0

Ok, this question is two-fold: 1) The actual file manupulation bit 2) Looping this manipulation in unix

Part 1)

I have two files:

File_1

a b
c d
e f
g h

and File_2

A B
C D
E F
G H
I J

i would like to get (in the first instance) the following result:

a b
A B
>
c d
A B
>
e f
A B
>
g h
A B

…and save this output to outfile1.

I gather I would have to use things like awk, cut and/or paste but I can’t manage to put it all together.

Part 2)

I then want to loop this manipulation for all rows in File_2 (note that the number of rows in File_1 is not the same as in File_2), such that I end up with 5 output files, where outfile2 would be:

a b
C D
>
c d
C D
>
e f
C D
>
g h
C D

and outfile3 would be:

a b
E F
>
c d
E F
>
e f
E F
>
g h
E F

etc.

At the moment I’m working in bash. Thank you in advance for any help!

  • 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-08T02:00:48+00:00Added an answer on June 8, 2026 at 2:00 am

    to make outfile_3(with E F) for example:

    x=$(sed -n '3p' File_2)
    awk "{ printf \"%s\\n%s\\n>\\n\", \$0, \"$x\" }" File_1 > outfile_3
    

    in first line '3p' cuts 3-rd line
    Now let’s do it in a loop:

    (( i = 1 ))
    while read line
    do
      awk "{ printf \"%s\\n%s\\n>\\n\", \$0, \"$line\" }" File_1 > "outfile_$i"
      (( i++ ))
    done < File_2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question has two parts. Part 1. Yesterday I had some code which would
This question is a bit of a two parter for .Net data services. This
This question is a bit of a two-parter. First, the title question. Here's what
Possible Duplicate: Two css files defining same class The answers to this question and
Ok so this question is two fold. I am creating a bill reminder app
This question has two parts (maybe one solution?): Sample vectors from a sparse matrix
I came across this question: say given two weights 1 and 3, u can
This question is regarding getopt function in php. I need to pass two parameter
This is an extension of this question: SQLite problem selecting two columns as one
I asked this question earlier: How to get delta between two text items But

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.