AWK / SED skript

Environment: SUN, tcsh
As a newbie in Unix scripts...
I need a script to take a file as a parameter (or piped into it)
and do the following:

1. search for a specific string
  (ie. "ORA-")
2. The search is for 2 or 3 diferent
3. The string case to search is upper
   and lower case.
4. If any of the search strings were
    found: output the line containing
    the string and the 3 lines before
    that string.

*** I managed to do all but number 4
    cat file_name |send -n -e '/ORA-/p'

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cat file_name | grep -B 3 -i 'ORA-'

what you mean "the search is for 2 or 3 diferent strings"?
if you need to search not only 'ORA-' words, e.g. ANOTHER word, try:

cat file_name | egrep -B 3 -i -e '(ORA\-)|(ANOTHER)'
Pleas comment on why den_tsopa's answer is wrong.  It looks like it should work to me.
This is comment on behalf Alonp,
Den_tsopa, the -B flag doesn't exists in SUN environment (at least not in 2.6)
well, there is another way:
cat file_name | perl -e 'while (<>) { push(@a,$_); shift @a if ($#a>3); print "--\n".join("",@a) if (/(ORA\-)|(ANOTHER)/); }'

it is not SED or AWK and now it will be comment (not answer) ;)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.