Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: need a script  (Read 4556 times)

0 Members and 1 Guest are viewing this topic.

wingmaker

  • Guest
need a script
« on: January 11, 2009, 07:54:26 AM »
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.

BatchRocks



    Hopeful
  • Thanked: 3
    Re: need a script
    « Reply #1 on: January 31, 2009, 08:16:55 PM »
    This forum.

    Dias de verano

    • Guest
    Re: need a script
    « Reply #2 on: February 03, 2009, 04:10:45 AM »
    This forum.


    Nope. Read the post, he wrote "bash script".


    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: need a script
    « Reply #3 on: February 03, 2009, 05:25:59 AM »
    This forum.


    Nope. Read the post, he wrote "bash script".



    I'll say LOL now, rather then after whatever BatchRocks posts next in this thread.  ;D
    I was trying to dereference Null Pointers before it was cool.

    anthonyf



      Starter

      Re: need a script
      « Reply #4 on: March 03, 2009, 12:29:11 PM »
      It's a one-liner...

      grep -B1 "ORA-" yourtextfilenamehere | grep -v ^\-\- > result.txt