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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:52:59+00:00 2026-06-07T00:52:59+00:00

I have a tab delimited file which looks like this: CHROM <TAB> POS <TAB>

  • 0

I have a tab delimited file which looks like this:

CHROM <TAB> POS <TAB> AD0062-C <TAB> AD0063-C <TAB> AD0065-C <TAB> AD0074-C 
2L <TAB> 440 <TAB>0/1:63:60,0,249 <TAB>0/1:89:86,0,166 <TAB>1/1:96:107,24,0<TAB>1/1:49:42,6,0  
2L <TAB> 260<TAB>0/1:66:63,0,207<TAB> 1/1:99:227,111,0<TAB>1/1:99:255,144,0<TAB> 1/1:49:42,6,0
2L <TAB> 595 <TAB> 0/1:11:85,0,8 <TAB>0/1:13:132,0,10 <TAB>0/1:73:70,0,131<TAB> 0/1:59:72,0,56

I want to select only the first 3 characters starting from column 3 so that I can get an output that looks like this:

CHROM <TAB> POS <TAB> AD0062-C <TAB> AD0063-C <TAB> AD0065-C <TAB> AD0074-C 
2L <TAB> 440 <TAB> 0/1 <TAB> 0/1 <TAB> 1/1 <TAB> 1/1  
2L <TAB> 260 <TAB> 0/1 <TAB> 1/1 <TAB> 1/1 <TAB> 1/1
2L <TAB> 595 <TAB> 0/1 <TAB> 0/1 <TAB> 0/1 <TAB> 0/1

Thanks

  • 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-07T00:53:00+00:00Added an answer on June 7, 2026 at 12:53 am

    Using awk. For every line but first one and if it has more that two fields, get substring of them. The print command it is for every line because it has no condition.

    awk '
        BEGIN { OFS = "\t" }
        NF > 2 && FNR > 1 { 
            for ( i=3; i<=NF; i++ ) { 
                $i = substr( $i, 1, 3 ) 
            } 
        } 
        { print }
    ' infile
    

    Output:

    CHROM   POS     AD0062-C        AD0063-C        AD0065-C        AD0074-C 
    2L      440     0/1     0/1     1/1     1/1
    2L      260     0/1     1/1     1/1     1/1
    2L      595     0/1     0/1     0/1     0/1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tab delimited file which looks like this: ABCA2 chr9 139021506 139043195
I have a file like this (tab delimited), but many lines 1314 0 0
Fellow Overflowers, I have a tab delimited csv file which contains dates in this
I have a large file named CHECKME which is tab delimited. There are 8
I have a file that is tab delimited. I would like a powershell script
Today I have just thrown together this PowerShell script which takes a tab-delimited text
I have a tab delimited file which is being parsed and then inserted into
I have 600 tab-delimited .txt files that look like this: barcode gene.symbol value 1
I have a tab delimited file in which starting from columns 10-25 some of
I have a tab delimited file on a shared path. I've setup that flat

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.