Find the answer to your Linux question:
Results 1 to 2 of 2
Hello, I need a bash script for the following situation: I have a text file and I need to extract every line that contains the expression "ORA-" and the line ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    1

    need a script

    Hello, I need a bash script for the following situation: I have a text file and I need to extract every line that contains the expression "ORA-" and the line above it. I would like the result to be redirected to a separate file named result.txt. Any help is apreciated. I am a beginer in shell scripting.

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Fortunately, this doesn't even require a script. There is a utility called "grep" whose job is to take a pattern and find lines that match it in a file. I suggest reading its man page ("man grep"), and you might pay attention to the -B option as well.

    Good luck.
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...