-2

I want to return logs with line

Process1A
Process2A
Process3A

The log file can have process 1A to 1000A or 1B to 1000B and so on but I only want to see process 1A to 3A. I dont want to include ProcessA (without 1, 2 or 3 in it) only in my result set. The log line has lots of information so character "A" can exist elsewhere in the line. I want to check the string specifically in the examples I listed above.

So something like this:

grep Process[1 or 2 or 3]A.*Result=Running scrape.log

but I dont know how to specify [1 or 2 or 3] with regexps.

Wiktor Stribiżew
  • 484,719
  • 26
  • 302
  • 397
bsobaid
  • 915
  • 1
  • 16
  • 30
  • Does this answer your question? [Reference - What does this regex mean?](https://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – baduker Jan 19 '21 at 15:53
  • Can you include a sample input with expected output – anubhava Jan 19 '21 at 15:56

1 Answers1

0

You have two ways for expressing OR:

  1. Character classes: [abc] for disjunction of characters
  2. Groups: (string1|string2|string3) disjunction of strings

So in your case you could use Process[123]A. See demo.

horcrux
  • 4,954
  • 5
  • 24
  • 35