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
  • 77,979
  • 13
  • 71
  • 125
Yamuna_dhungana
  • 643
  • 3
  • 9

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
  • 96,430
  • 6
  • 33
  • 74