0

I have a string that looks like this:

RG="@RG\tID:HS2000-1015_160.7\tDS:ADNI_1380^LP6005117-DNA_G04^ADNI_WGS\tLB:LP6005117-DNA_G04\tPL:illumina\tPU:HS2000-1015_160.7\tSM:ADNI_1380"

I want to extract everything after ID: and before first the \t

and get HS2000-1015_160.7 as a result. I would like a one-liner if possible.

code I tried:

echo ${RG} | grep -oP "(?<=ID:)[^"\t"]*" 

which gives me HS2000-1015_160.7\

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Yamuna_dhungana
  • 653
  • 4
  • 10

1 Answers1

1

Try:

sed 's/.*ID://;s/\\t.*//'
  • s/.*ID:// remove everything in front and including ID:
  • s/\\t.*//' remove everything after and including \t characters.
KamilCuk
  • 120,984
  • 8
  • 59
  • 111