Issue
I am trying to extract the JIRA Ticket number from a string.
The Jira ticket might be mentioned any where in the line like:
I just want REL-12345 as the output.
Can someone please help. Thanks!
Solution
grep -Eow 'REL-[0-9]+'
+
is one or more, to specifiy N numbers (eg 5):
grep -Eow 'REL-[0-9]{5}
- Ranges:
{3,6}
is 3 to 6,{5,}
is 5 or more, etc. - On GNU/Linux:
man grep -> /Repetition
for more details. -o
prints only matching strings-w
matches full words only, ie. to avoid matchingWREL-12345
(for example)grep -Eow 'REL-[[:alnum:]]+'
for both letters and numbers (afterREL-
).
Answered By - dan Answer Checked By - Mary Flores (WPSolving Volunteer)