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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:35:40+00:00 2026-06-11T10:35:40+00:00

>cat /tmp/list1 john jack >cat /tmp/list2 smith taylor It is guaranteed that list1 and

  • 0
>cat /tmp/list1
john
jack

>cat /tmp/list2
smith
taylor

It is guaranteed that list1 and list2 will have equal number of lines.

    f(){
        i=1
        while read line
          do
        var1 = `sed -n '$ip' /tmp/list1`
        var2 = `sed -n '$ip' /tmp/list2`
        echo $i,$var1,$var2
        i=`expr $i+1`
            echo $i,$var1,$var2
          done < $INFILE
    }

So output of f() should be:

1,john,smith
2,jack,taylor

But getting

1,p,p
1+1,p,p

If i replace following:

var1 = `sed -n '$ip' /tmp/list1`
var2 = `sed -n '$ip' /tmp/list2` 

with this:

var1=`head -$i /tmp/vip_list|tail -1`
var2=`head -$i /tmp/lb_list|tail -1`

Then output:

1,john,smith
1,john,smith
  • 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-11T10:35:41+00:00Added an answer on June 11, 2026 at 10:35 am

    If you can use paste and awk command, you can achieve the same with a one-liner:

    paste -d, /tmp/list1 /tmp/list2 | awk '{print NR "," $0}'
    

    Replace the while script with this line 🙂

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

Sidebar

Related Questions

I have these: $ cat a.tmp ABB.log ABB.log.122 ABB.log.123 I wanted to find a
I have a script. It runs without warnings. $ cat ~/tmp/so1.scala import org.yaml.snakeyaml.Yaml class
I have a file frequencies.xml which contains lines with this form: <?xml version=1.0?> <!DOCTYPE
I have a make build system that I am trying to decipher that someone
I'm have some php code: <? $cmd=mkfifo /tmp/myfifo;; system($cmd); $cmd=echo 1 > /tmp/myfifo 2>&1
I have a code snippet, as follows. #!/bin/bash filename=tmp_list_filenames line_index=0 cat $filename | while
I have a file named cmd that contains a list of Unix commands as
Note: # cat /tmp/foo - regular file /lib/a.lib /lib/b.lib /lib/c.lib /lib/d.lib cat /tmp/foo |
TMP=$$.FILE #Process puts contents into TMP cat $TMP | sort | head > $TMP
TMP=$$.FILE #Process puts contents into TMP cat $TMP | sort | head > $TMP

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.