I want to get the numbers after the B*, but not including Y and after it. I tried to use this command which I got from a friend, but it doesn't work:
grep -oP 'B.\K[\w\s\d]' < tus.txt | sort -u
tus.txt
~TUS*21424565*4716129*B*222791885833*Y*
~TUS*21470045*4733746*B*36*Y*19-OCT-16**B*2239681
~TUS*21758806*4932668*B*00081907*Y*2707826
~TUS*21758851*4932694*B*00082025*Y*2707871
~TUS*21758862*4932739*B*262105589241-20172-31489016
~TUS*21758767*4932626*B*00081684*Y*2707792
~TUS*21758861*4932693*B*00082024*Y*2707881
~TUS*21758895*4932764*B*4578873831221*Y*
~TUS*21760350*4933404*B*00082603*Y*2708838
~TUS*21759295*4932379*B*00082403*Y*2708332
Desired result:
222791885833
36
00081907
00082025
262105589241-20172-31489016
00081684
00082024
4578873831221
00082603
00082403