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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:58:57+00:00 2026-05-27T15:58:57+00:00

This maybe extension from the question: Incorporate variables into bash code line I just

  • 0

This maybe extension from the question:
Incorporate variables into bash code line

I just realize in my text, lines actually come in variable format.

2   118610455   P2_PM_2_5034    T   <DUP:TANDEM>    40  .   END=118610566;SVLEN=110;SVTYPE=TDUP;CIPOS=-100,55;CIEND=-56,100;IMPRECISE;DBVARID=esv7540;VALIDATED;VALMETHOD=CGH;SVMETHOD=RP 

1   859214  P2_M_061510_1_73    C   <DEL>   .   .   CIEND=-130,50;CIPOS=-57,93;END=860180;IMPRECISE;SVLEN=-966;SVTYPE=DEL;VALIDATED;DBVARID=esv10036;VALMETHOD=CGH;SVMETHOD=RD,RP

What I need is

2 118610455 118610566
1 859214 860180

Just as shown in above, this "END=#" may come in different positions at 8th column. So basically I need to find “END=..” part from 8th column first, then grep the number.
So this is actually about how to grep specific pattern from string ( in this case, the pattern is “END=”)

But how can I do that?
thx

  • 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-27T15:58:58+00:00Added an answer on May 27, 2026 at 3:58 pm

    Grep:

    You can use the -o option of grep for your search:

    Test:

    [jaypal:~/Temp] grep -o "END=[0-9]\+;" file | tr -ds 'END=|;' ''
    118610566
    860180
    

    But if you are looking for a complete solution then how about using awk (sorry I know this wasn’t your requirement. But here are two solutions:

    Awk:

    If the first and second parameters you want do not vary in position, then we can split each values in specific fields and then loop over each of them. As soon as we reach a field that is END we print the $1 and $4 and then print the column next to END.

    awk -v FS="[ ;=]" '{for(i=1;i<=NF;i++) if ($i=="END") print $1,$4,$(i+1)}' file
    

    Test:

    [jaypal:~/Temp] cat file
    2   118610455   P2_PM_2_5034    T   <DUP:TANDEM>    40  .   END=118610566;SVLEN=110;SVTYPE=TDUP;CIPOS=-100,55;CIEND=-56,100;IMPRECISE;DBVARID=esv7540;VALIDATED;VALMETHOD=CGH;SVMETHOD=RP 
    1   859214  P2_M_061510_1_73    C   <DEL>   .   .   CIEND=-130,50;CIPOS=-57,93;END=860180;IMPRECISE;SVLEN=-966;SVTYPE=DEL;VALIDATED;DBVARID=esv10036;VALMETHOD=CGH;SVMETHOD=RD,RP
    
    [jaypal:~/Temp] awk -v FS="[ ;=]" '{for(i=1;i<=NF;i++) if ($i=="END") print $1,$4,$(i+1)}' file
    2 118610455 118610566
    1 859214 860180
    

    GNU AWK:

    If you have gawk then it has a built-in function called gensub. That supports back references. So you can also do the following –

    gawk '{print $1,$2,gensub(/.*\<END\>=(.[^;]*);.*/,"\\1",$0)}' file
    

    Test:

    [jaypal:~/Temp] gawk '{print $1,$2,gensub(/.*\<END\>=(.[^;]*);.*/,"\\1",$0)}' file
    2 118610455 118610566
    1 859214 860180
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this maybe a basic question but I just can't seem to find
This maybe a stupid question, but as I can not easily undo my change
this maybe a noobish question so sorry, is it possible to run c programmes
I know this maybe a very basic question but I'm having a bit of
Ok so this maybe a simple/silly question but I don't know so here goes:
This is maybe an oblique question: I'm writing an emulator in VB6 (silly me).
This question maybe a better fit on The Business of Software forum but despite
Maybe this is a dumb question, but is there any way to convert a
Maybe this applied to other Delphi's (I've only used 7). We've got our code
maybe this is a stupid question, but i have seen many Tuts that build

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.