Re: Splitting file



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
.



Relevant Pages

  • Re: Splitting file
    ... No row was found for FETCH, UPDATE or DELETE; ... query is an empty table. ... UPDATE TABLE1 SET ... ...
    (comp.unix.shell)
  • Splitting file
    ... UPDATE TABLE1 SET ... ... No row was found for FETCH, UPDATE or DELETE; ... query is an empty table. ...
    (comp.unix.shell)
  • 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: 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)
  • Re: Updating the first row which is null
    ... I am trying to update table1 and set a new value with a condition ... The query executes but it doesn t not update the informations. ... UPDATE table1 SET table1.Name = newName ... Updating the first row which is null ...
    (comp.databases.ms-access)