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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:00:02+00:00 2026-06-15T12:00:02+00:00

I am trying to modify text files using awk. There are three columns and

  • 0

I am trying to modify text files using awk. There are three columns and I want to delete part of the text in the first column:

range=chr1      20802865        20802871        
range=chr1      23866528        23866534

to

chr1      20802865        20802871        
chr1      23866528        23866534

How can I do this?

I’ve tried awk '{ substr("range=chr*", 7) }' and awk '{sub(/[^[:space:]]*\\/, "")}1' but it deletes all the contents of the file.

  • 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-15T12:00:03+00:00Added an answer on June 15, 2026 at 12:00 pm

    Set the field separator as = and print the second field:

    # With awk                                                                     
    $ awk -F= '{print $2}' file
    chr1      20802865        20802871        
    chr1      23866528        23866534
    
    # Or with cut
    $ cut -d= -f2 file                  
    chr1      20802865        20802871        
    chr1      23866528        23866534
    
    # How about grep
    $ grep -Po '(?<==).*' file
    chr1      20802865        20802871        
    chr1      23866528        23866534
    
    # Temp file needed
    $ cut -d= -f2 file > tmp; mv tmp file
    

    Both awk, cut and grep require temporary files if you want to store the changes back into file, a better solution would be to use sed:

     sed -i 's/range=//' file
    

    This substitutes range= with nothing and the -i means the changes are done in-place so no need to handle the temporary files stuff as sed does it for you.

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

Sidebar

Related Questions

I am trying to modify emails stored as text files. I first import a
I'm trying to modify the text of a Label component that I already placed
I am trying to modify the android lvl library and as part of this
I am trying to modify javascript files in a Ruby on Rails application in
I have an XML file I'm trying to modify and want to add a
I'm trying to find some text in an XML file and delete only a
I'm trying to write a simple client-side text editor using HTML5 and Javascript. Is
I am trying to modify an applescript that takes a text file, and creates
I'm trying to modify the Orchard.Search part with the search form and button to
I'm trying to modify an svg tag with javascript to make it resizable, but

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.