sed or operator

hi,

I got a requirement to change existing script like below to search additional pattern "DB select". i tried using \| opearator but it is not working :(. Below is the existing code

echo $(cat ${1} |sed -n '/Error  in/ {
        N
        N
        N
        /Too many/ {
          p
          }
        }' >>${tmpfile})

I need to search "Too many" or "DB select"

Can some one help in this?

Below is the code i tried executing

echo $(cat ${1} |sed -n '/Error  in/ {
        N
        N
        N
        /Too many\|DB select/ {
          p
          }
        }' >>${tmpfile})

Regards,
Jairam

You can come at it negatively:

/regex1/!d
/regex2/!d

where the list can have any length, and you you can d, b or "b target_tag" to each as is appropriate. Anything else falls through.

BTW, beware some sed have a bug that drops data for N at $=EOF. You can sometimes just '$!N'.

1 Like

I didn't know that , thx for the tip !

That's not a bug. That's the intended behavior according to POSIX. Some SED implementations (for example GNU) choose to disregard the fact that N should not print if EOF is reached and behave differently.

See the following for more info:
Reporting Bugs - sed, a stream editor
sed

Regards,
Alister

I thoght that setting the variable POSIXLY_CORRECT to some value fixed that one. Am I wrong?

You are correct, jim.