Re: Splitting file
- From: AFC <annecarterfredi@xxxxxxxxx>
- Date: Mon, 30 Jul 2007 11:00:05 -0700
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!!
.
- References:
- Splitting file
- From: AFC
- Re: Splitting file
- From: Janis Papanagnou
- Splitting file
- Prev by Date: Re: Splitting file
- Next by Date: calling functions in awk
- Previous by thread: Re: Splitting file
- Next by thread: calling functions in awk
- Index(es):
Relevant Pages
|