Re: Splitting file



On Jul 30, 1:20 pm, Janis Papanagnou <Janis_Papanag...@xxxxxxxxxxx>
wrote:
AFC wrote:
I have a file with 150,000+ lines. Text in the file have this pattern:

UPDATE TABLE1 SET ...
The SQL command completed successfully.

UPDATE TABLE1 SET ...
The SQL command completed successfully.

UPDATE TABLE1 SET ...
The SQL command completed successfully.

UPDATE TABLE1 SET ...
No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table.

UPDATE TABLE1 SET ...
No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table.

UPDATE TABLE1 SET ...
No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table.

UPDATE TABLE1 SET ...
The SQL command completed successfully.

UPDATE TABLE1 SET ...
The SQL command completed successfully.

UPDATE TABLE1 SET ...
The SQL command completed successfully.

UPDATE TABLE1 SET ...
No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table.

UPDATE TABLE1 SET ...
No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table.
.
.
.

What I need to do is to make two files by moving all double lines
(after an empty line) to one file and all tripple lines to another
file.
So, one file has:
UPDATE TABLE1 SET ...
The SQL command completed successfully.

UPDATE TABLE1 SET ...
The SQL command completed successfully.
.
.
.

and another file has:
UPDATE TABLE1 SET ...
No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table.

UPDATE TABLE1 SET ...
No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table.
.
.
.

What command should I use to achieve this...Thanks for your help.

Use awk.

awk 'BEGIN{RS="";FS="\n";ORS="\n\n"}{print >"file_"NF}' data

...will create two files, file_2 and file_3, with the respective lines.

Janis- Hide quoted text -

- Show quoted text -

Wow! That's exactly what I was looking for. Thanks a lot!!

.



Relevant Pages

  • Re: Question about SqlCe Parameters usage
    ... but how can I make a Query in qhich I specify the range of index ... you create an empty table and fill it with a SQL query which only ... > done a query which specified the range of index to fetch, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: List thread safety question
    ... > Actually I fetch the first item from the List, to process it, ... This will still loop until the queue is empty, ... It might also need a PulseAll or something at ... the end of each iteration to invite the other threads to the party... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Deleting rows from a table in SQL
    ... SQL0100W No row was found for FETCH, UPDATE or DELETE; ... query is an empty table. ... If your able to interrogate sql error or state and ... Then when you want to empty it: ...
    (comp.lang.rexx)
  • Right click > New list
    ... When you Right-click> New on an empty place ... you fetch up a list of file types that you can create. ... There's an item in it that I want to get rid of. ...
    (microsoft.public.windowsxp.general)
  • Re: Splitting file
    ... UPDATE TABLE1 SET ... ... No row was found for FETCH, UPDATE or DELETE; ... query is an empty table. ...
    (comp.unix.shell)