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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:21:53+00:00 2026-06-17T09:21:53+00:00

I am new to linux and the command line. I am trying to find

  • 0

I am new to linux and the command line. I am trying to find a command to that will allow me to replace white space (in a .csv text file) with a semi-colon for all fields except the first. Please see example below, any help would be gratefully received, I have spent a long time looking for a solution. If you do have an answer could you please explain the command so I can try and learn how and why. Many thanks.

Example of input text:

0   k__Bacteria  p__Firmicutes   c__Bacilli             
1   k__Bacteria  p__Firmicutes   c__Clostridia      
2   k__Bacteria  p__Bacteroidetes    c__Bacteroidia     
3   k__Bacteria  p__Bacteroidetes    c__Bacteroidia

What I need the out put to be:

0   k__Bacteria;p__Firmicutes;c__Bacilli        
1   k__Bacteria;p__Firmicutes;c__Clostridia    
2   k__Bacteria;p__Bacteroidetes;c__Bacteroidia   
3   k__Bacteria;p__Bacteroidetes;c__Bacteroidia
  • 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-17T09:21:54+00:00Added an answer on June 17, 2026 at 9:21 am
    $ cat file
    0   k__Bacteria  p__Firmicutes   c__Bacilli     foo     bar
    1   k__Bacteria  p__Firmicutes   c__Clostridia  the   quick     brown
    2   k__Bacteria  p__Bacteroidetes    c__Bacteroidia     fox jumped      over
    3   k__Bacteria  p__Bacteroidetes    c__Bacteroidia     the lazy dogs back
    
    $ awk -v skip=1 '{match($0,"([^[:space:]]+[[:space:]]+){"skip"}"); head=substr($0,1,RSTART+RLENGTH); tail=substr($0,RSTART+RLENGTH+1); gsub(/[[:space:]]+/,";",tail); print head tail}' file
    0   k__Bacteria;p__Firmicutes;c__Bacilli;foo;bar
    1   k__Bacteria;p__Firmicutes;c__Clostridia;the;quick;brown
    2   k__Bacteria;p__Bacteroidetes;c__Bacteroidia;fox;jumped;over
    3   k__Bacteria;p__Bacteroidetes;c__Bacteroidia;the;lazy;dogs;back
    
    $ awk -v skip=2 '{match($0,"([^[:space:]]+[[:space:]]+){"skip"}"); head=substr($0,1,RSTART+RLENGTH); tail=substr($0,RSTART+RLENGTH+1); gsub(/[[:space:]]+/,";",tail); print head tail}' file
    0   k__Bacteria  p__Firmicutes;c__Bacilli;foo;bar
    1   k__Bacteria  p__Firmicutes;c__Clostridia;the;quick;brown
    2   k__Bacteria  p__Bacteroidetes;c__Bacteroidia;fox;jumped;over
    3   k__Bacteria  p__Bacteroidetes;c__Bacteroidia;the;lazy;dogs;back
    
    $ awk -v skip=3 '{match($0,"([^[:space:]]+[[:space:]]+){"skip"}"); head=substr($0,1,RSTART+RLENGTH); tail=substr($0,RSTART+RLENGTH+1); gsub(/[[:space:]]+/,";",tail); print head tail}' file
    0   k__Bacteria  p__Firmicutes   c__Bacilli;foo;bar
    1   k__Bacteria  p__Firmicutes   c__Clostridia;the;quick;brown
    2   k__Bacteria  p__Bacteroidetes    c__Bacteroidia;fox;jumped;over
    3   k__Bacteria  p__Bacteroidetes    c__Bacteroidia;the;lazy;dogs;back
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Linux and it's command line and I need to change user
How to run testng.xml file from maven commands in linux command line? I am
Okay, I'm very new to linux and command line, and fairly new to java.
I'm looking for a simple command-line tool (on Linux) to insert a text chunk
I am very new to the linux/unix command line and I am having some
I am trying to implement some kind of new Linux task scheduler so I
I'm very new to Linux and programming on Linux. I'm trying to install OpenAL
I am trying to build a script (I'm pretty new to linux scripting) and
I am new to Linux and using Ubuntu, trying to install firefox-4.0b1.tar.bz2 but don't
I'm trying to find or implement a simple solution that can sequentially queue up

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.