DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: URGENT UNIX HELP - editing a file

  1. #1
    Join Date
    Jun 2001
    Location
    NY
    Posts
    226
    Dear members

    I have a file with the several of the following create statements. I want to edit and delete everthing between 'STORAGE' and 'DEFAULT', can someone please tell me how I can either use vi, SED or any other unix tool to achieve this task?
    Thanks a lot in advance.


    CREATE UNIQUE INDEX "WWFSPROD"."PS_JRNLGEN_SEL_21" ON "PS_JRNLGEN_SEL_21" "PROCESS_INSTANCE" , "CHARTFIELD" , "RANGE_FROM_21" , "RANGE_TO_21" ) PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE (INITIAL 122880 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 495 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "FSAPP_INDEX" LOGGING ;

    roukie-dba

  2. #2
    Join Date
    Oct 2001
    Location
    Madrid, Spain
    Posts
    763
    In vi:

    :g/old_string/s//new_string/g

    Take care because you probably have the create for tables and indexes.

    Cheers

    Angel

  3. #3
    Join Date
    Apr 2001
    Location
    London
    Posts
    725
    using vi

    press esc then press x

    x is the same as hitting delete button. Will delete 1 character at a time after cursor.

    esc i - insert
    esc R - replace

    esc wq - save and exit.
    Once you have eliminated all of the impossible,
    whatever remains however improbable,
    must be true.

  4. #4
    Join Date
    Jun 2001
    Location
    NY
    Posts
    226
    Thanks for the replies so far, however, I am trying to delete from several create statements ALL the words between STORAGE and DEFAULT inclusive!!! Please review and help.

    Thanks again.
    roukie-dba

  5. #5
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    342
    You could try something like this.

    The -F option tells awk to treat "STORAGE" as a field separator.
    Using substr+index function we take the after-"DEFAULT" part
    In this example, t is the filename of the source


    awk -F STORAGE '{
    printf $1
    printf "----- everything you want to put between STORAGE and DEFAULT -----"
    print substr($2,index($2,"DEFAULT")+8)
    }' t

    hope this helps
    Gert


  6. #6
    Join Date
    May 2002
    Posts
    108
    Hi

    Check out if u can FTP your file to any windows desktop environment... edit and put it back again !

    There is no short cut in UNIX to remove lines
    between STORAGE and DEFAULT for the whole file.

    Still u can delete few lines together
    in UNIX as follows ndd where 'n' stands for
    the number of lines you want to delete
    ex., 10dd deletes 10 lines from the cursor
    position.

    Search for the word STORAGE, then delete till
    rest of the line by pressing D (pls note
    vi is case sensitive too!). Delete the lines
    following it till DEFAULT, as said before.

    NOTE :

    dd - deletes a line
    5dd - deletes 5 lines
    dw - deletes a word
    D - deletes till end of line from the
    cursor position

    /findwhat - will search down for the word 'findwhat'
    in the file from cursor position

    May not be what u want.... but probably
    would help u in editing ur file.


    Cheers
    Nandu

    Never give up !

    Nanda Kumar - Vellore

  7. #7
    Join Date
    Mar 2001
    Posts
    314
    awk '{ FS = "STORAGE | DEFAULT\)" } { print $1, $3}' < your file >

    -amar

  8. Posting Permissions

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


Click Here to Expand Forum to Full Width