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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:41:51+00:00 2026-06-08T05:41:51+00:00

I have a space delimited input text file. I would like to delete columns

  • 0

I have a space delimited input text file. I would like to delete columns where the column header is size using sed or awk.

Input File:

id quantity colour shape size colour shape size colour shape size
1 10 blue square 10 red triangle 8 pink circle 3
2 12 yellow pentagon 3 orange rectangle 9 purple oval 6

Desired Output:

id quantity colour shape colour shape colour shape
1 10 blue square red triangle pink circle
2 12 yellow pentagon orange rectangle purple oval
  • 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-08T05:41:53+00:00Added an answer on June 8, 2026 at 5:41 am

    awk command

    awk '
    NR==1{
        for(i=1;i<=NF;i++)
            if($i!="size")
                cols[i]
    }
    {
        for(i=1;i<=NF;i++)
            if(i in cols)
                printf "%s ",$i
        printf "\n"
    }' input > output
    

    pretty printing

    column -t -s ' ' output 
    

    result

    id  quantity  colour  shape     colour  shape      colour  shape
    1   10        blue    square    red     triangle   pink    circle
    2   12        yellow  pentagon  orange  rectangle  purple  oval
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a space delimited text file, from which I need to extract individual
I have a file like this (which is space delimited): AX-18 Chr1_419085 1 41908545
I have a file which is space delimited which looks like this: probeset_id submitted_id
The problem I have a tab delimited input file that looks like so: Variable
I have a space in which I would like certain elements (represented here by
I would like to have some space between the same line.. I know there
I have a large txt file space delimited which I split into 18 smaller
I have a space delimited list of files names, where spaces in the file
I have created a Space Invaders Game using an example game + source. Using
I'd like to create a dynamic Multidimensional ArrayList that reads from a text file

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.