Re: Splitting file
- From: Janis Papanagnou <Janis_Papanagnou@xxxxxxxxxxx>
- Date: Mon, 30 Jul 2007 19:20:05 +0200
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
.
- Follow-Ups:
- Re: Splitting file
- From: AFC
- Re: Splitting file
- References:
- Splitting file
- From: AFC
- Splitting file
- Prev by Date: Splitting file
- Next by Date: Re: Splitting file
- Previous by thread: Splitting file
- Next by thread: Re: Splitting file
- Index(es):
Relevant Pages
|