-2

Need to find the words/strings from the file, First 4 character of the line should be "ORA-" and the next 5 character should be numeric.

File Name: 1.txt

This is test ORA-12345
ORA-01234test
OORA-06550:
ORA-01A34

O/P:

ORA-01234test

Command:

egrep "ORA-[0-9]" 1.txt

Can not check first 4 should br ORA- and next 5 should be numeric

Munu
  • 103
  • 5
  • 15
  • 2
    `ORA-[0-9]{5}`? –  Jan 20 '20 at 09:56
  • Have a look at: [**POSIX Basic Regular Expressions**: _BREs Matching Multiple Characters_](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_06) and [RegularExpressions.info :: Repeat](https://www.regular-expressions.info/repeat.html) – kvantour Jan 20 '20 at 12:49

1 Answers1

1

You need to precise that you want 5 digits ({5}) and match from the start of the line with ^, to avoid matching OORA-06550:.

egrep "^ORA-[0-9]{5}" 1.txt
Benoît Zu
  • 1,217
  • 12
  • 22