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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:58:05+00:00 2026-05-23T03:58:05+00:00

I want to delete text after the first colon : (inclusive), or replace it

  • 0

I want to delete text after the first colon : (inclusive), or replace it with nothing.

For example, 1:5:30 should be changed into 1. I prefer an awk script to perform this job. But I do not know how to do that. Could you please give me any directions? Thanks in advance.

My data are tab-delimited, and the file looks like there are points in some cells.

1       313     .       T       C       30.11        1:5:30  .       .       .
1       316     .       A       T       30.80        1:5:30  .       0:8:28  .
1       317     .       T       A       31.40        1:5:36  .       0:8:28  .

I tried the following, but I failed with all of them:

sed 's/:*:*//g' mydatafile
sed 's/:[0-9]:[0-9]//g' mydatafile
  • 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-05-23T03:58:05+00:00Added an answer on May 23, 2026 at 3:58 am

    Bit unclear what the desired output should be, but this is my interpretation, using sed:

    $ sed 's/:.*//' input
    1   313 .   T   C   30.11   1
    1   316 .   A   T   30.80   1
    1   317 .   T   A   31.40   1
    

    Using awk:

    $ awk -F":" '{print $1}' input
    1   313 .   T   C   30.11   1
    1   316 .   A   T   30.80   1
    1   317 .   T   A   31.40   1
    

    Using Cut:

    cut -d":" -f1 input
    

    Using bash:

    IFS=':'
    
    while read a b; do
        echo $a
    done < input
    

    Alternative interpretation using awk:

    $ awk 'BEGIN {OFS="\t"} {sub(/:.*/,"",$7); print}' input
    1   313 .   T   C   30.11   1   .   .   .
    1   316 .   A   T   30.80   1   .   0:8:28  .
    1   317 .   T   A   31.40   1   .   0:8:28  .
    

    3rd and hopefully last update

    3rd interpretation using awk:

    $ awk 'BEGIN {OFS="\t"} {for (i=1;i<NF;i++){sub(/:.*/,"",$i)}; print}' input
    1   313 .   T   C   30.11   1   .   .   .
    1   316 .   A   T   30.80   1   .   0   .
    1   317 .   T   A   31.40   1   .   0   .
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to replace a specific amount of text after searching for something with
I want to delete a range of data from a text file using PHP.
I want to delete an DOM element right after fading out. What I did
I am scraping HTML file using BeautifulSoup in python. I want to delete text
I want to delete everything up to the cursor or after the cursor or
I want to delete some certain characters that used wrongly in a string. ........I.wanna.delete.only.the.dots.outside.of.this.text...............
how to setting display:none to some div after I delete the text from textarea
I have certain text added to all my files. I want to delete that
Hey guys i wrote a quick test. I want delete to call deleteMe which
I want to delete foo() if foo() isn't called from anywhere.

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.