Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004
    Posts
    1

    Arrow Unanswered: Deleting lines from line 40 to end of the file using korn shell

    Hi,

    I 'm new to shell script and seems like you answered lot of questions in shell, Please help me to answer this question,

    I have a file called temp1.txt, data in this file is

    abcd text1 text2 sdksjdj
    ands text2 text isudiusd
    DELETE D D SDSDS
    DELETE D D DFSSDSD

    I would like to delete everything after DELETE and put it in a file, everything before DELETE I would like to put it in another file, basically I want to split the data in to two files, is there a way to do this in korn shell?

    Please help.
    Thanks.
    Kondal

  2. #2
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    This is to put all the lines that start with 'DELETE" in one file (with '.del' suffix) and all the others in the other (with the '.nor).

    Save the attached code as 'ky.awk' file and:

    nawk -f ky.awk temp1.txt

    Code:
    BEGIN {
       SUF_delete=".del"
       SUF_normal=".nor"
    }
    /^DELETE/ { print >> (FILENAME SUF_delete) ; next}
    { print >> (FILENAME SUF_normal) }
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

Posting Permissions

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