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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:14:13+00:00 2026-06-09T13:14:13+00:00

I need to extract the first column from an arbitrary number of files and

  • 0

I need to extract the first column from an arbitrary number of files and print the columns with empty lines for the missing entries. Having trouble with the blank lines part. Like so:

File1:
Alfa        Something    More stuff
Charlie     Something    More stuff
Delta       Something    More stuff
Echo        Something    More stuff
Foxtrot     Something    More stuff

File2:
Alfa        Something    More stuff
Bravo       Something    More stuff
Echo        Something    More stuff
Foxtrot     Something    More stuff

File3:
Alfa        Something    More stuff
Bravo       Something    More stuff
Charlie     Something    More stuff
Delta       Something    More stuff
Echo        Something    More stuff

Output:
FileName1    FileName2    FileName3
=========    =========    =========
Alfa         Alfa         Alfa
             Bravo        Bravo
Charlie                   Charlie
Delta                     Delta
Echo         Echo         Echo
Foxtrot      Foxtrot
  • 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-09T13:14:15+00:00Added an answer on June 9, 2026 at 1:14 pm

    Here’s one way to do it, other than some minor formatting issues:

    awk '
      { 
        exists[$1] = 1;
        files[$1,ARGIND] = 1;
      }
      END {
        for (i=1; i<ARGC; ++i) {
          printf("%-20s",ARGV[i])
        }
        printf("\n");
        for (i=1; i<ARGC; ++i) {
          printf("%-20s","=================")
        }
        printf("\n");
        for (name in exists) {
          for (i=1; i<ARGC; ++i) {
            if (files[name,i]) {
              printf("%-20s",name);
            }
            else {
              printf("%-20s","");
            }
          }
          printf("\n");
        }
      }
    ' file1 file2 file3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to extract .co.uk urls from a file with lots of entries, some .com
I need to extract the first URL from some content. The content may be
In the app I'm working on, I need to extract the first word from
I am trying to extract columns from multiple text files(3000 files). The sample of
I have to read some external files, extract some columns and complete the missing
I need to extract a value from a hidden HTML field, have somewhat figured
I need to extract the URL's from the php datas, how can i achieve
I need to extract the arguments from a function Say, Function_1(arg1,agr2,....argn). Is it possible
I need to extract images from a FB fan page. I'm able to read
I need to extract some data from a CSV file. The CSV is a

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.