I have a textfile named tmp.txt which contains the following record:
Please help me to have another file named out.txt with this format based on tmp.txt:
I need to get ARCHIVING DATABASE, the word that follows that and then continue with information when I see the word TABLE, VIEW or MACRO. Here's what I have started, please feel free to suggest any solution. But I cannot get the other lines.
Code:
06/13/2007 23:05:23 ARCHIVING DATABASE "table1"
06/13/2007 23:05:28 "table1" - LOCK RELEASED
06/13/2007 23:05:28
06/13/2007 23:05:28 ARCHIVING DATABASE "arctab3"
06/13/2007 23:05:30 TABLE "ARCHIVE_DB" - 438 BYTES, 0 ROWS ARCHIVED FOR THIS
STREAM
06/13/2007 23:05:30 TABLE "tab3" - 438 BYTES, 0 ROWS ARCHIVED FOR
THIS STREAM
06/13/2007 23:05:30 TABLE "tab2" - 438 BYTES, 0 ROWS ARCHIVED
FOR THIS STREAM
06/13/2007 23:05:30 TABLE "table8" - 438 BYTES, 0 ROWS ARCHIVED
FOR THIS STREAM
06/13/2007 23:05:35 ARCHIVING DATABASE "DBA_INFO"
06/13/2007 23:05:37 TABLE "Accountinfo" - 57,757 BYTES, 725 ROWS ARCHIVED FOR
THIS STREAM
06/13/2007 23:05:37 TABLE "AccountInfo_V2R4" - 53,312 BYTES, 644 ROWS
ARCHIVED FOR THIS STREAM
06/13/2007 23:05:41 TABLE "AllRights" - 44,077,114 BYTES, 477,103 ROWS
ARCHIVED FOR THIS STREAM
06/13/2007 23:05:41 TABLE "canary" - 80,438 BYTES, 5,000 ROWS ARCHIVED FOR
THIS STREAM
06/13/2007 23:05:41 TABLE "Child_Allrights" - 27,727 BYTES, 201 ROWS ARCHIVED
FOR THIS STREAM
06/13/2007 23:05:42 TABLE "column_exclude_list" - 512 BYTES, 3 ROWS ARCHIVED
FOR THIS STREAM
06/13/2007 23:05:42 TABLE "dba_userid" - 11,938 BYTES, 94 ROWS ARCHIVED
FOR THIS STREAM
06/13/2007 23:05:42 TABLE "dba_useridx" - 7,018 BYTES, 53 ROWS ARCHIVED
FOR THIS STREAM
06/13/2007 23:05:42 VIEW "LOBJTBL" - ARCHIVED
06/13/2007 23:05:42 VIEW "LOGTBL" - ARCHIVED
06/13/2007 23:05:42 VIEW "sqltbl" - ARCHIVED
06/13/2007 23:05:42 VIEW "summarytbl" - ARCHIVED
06/13/2007 23:05:42 TABLE "DB_DEF_ACCOUNT" - 41,353 BYTES, 439 ROWS
ARCHIVED FOR THIS STREAM
06/13/2007 23:05:42 TABLE "useridtab" - 658 BYTES, 0 ROWS ARCHIVED FOR
THIS STREAM
06/13/2007 23:05:42 MACRO "GENERATE_VIEW" - ARCHIVED
06/13/2007 23:05:42 VIEW "INDICES" - ARCHIVED
06/13/2007 23:05:43 TABLE "Parent_Allrights" - 7,072 BYTES, 48 ROWS ARCHIVED
FOR THIS STREAM
06/13/2007 23:05:43 MACRO "macro1" - ARCHIVED
06/13/2007 23:05:43 MACRO "MACRONODE2" - ARCHIVED
Please help me to have another file named out.txt with this format based on tmp.txt:
Code:
ARCHIVING DATABASE "table1"
ARCHIVING DATABASE "arctab3" TABLE "ARCHIVE_DB" - 438 BYTES, 0 ROWS
ARCHIVING DATABASE "arctab3" TABLE "tab3" - 438 BYTES, 0 ROWS
ARCHIVING DATABASE "arctab3" TABLE "tab2" - 438 BYTES, 0 ROWS
ARCHIVING DATABASE "arctab3" TABLE "table8" - 438 BYTES, 0 ROWS
ARCHIVING DATABASE "DBA_INFO" TABLE "Accountinfo" - 57,757 BYTES, 725 ROWS
ARCHIVING DATABASE "DBA_INFO" TABLE "AccountInfo_V2R4" - 53,312 BYTES, 644 ROWS
ARCHIVING DATABASE "DBA_INFO" TABLE "AllRights" - 44,077,114 BYTES, 477,103 ROWS
ARCHIVING DATABASE "DBA_INFO" TABLE "canary" - 80,438 BYTES, 5,000 ROWS
ARCHIVING DATABASE "DBA_INFO" TABLE "Child_Allrights" - 27,727 BYTES, 201 ROWS
ARCHIVING DATABASE "DBA_INFO" TABLE "column_exclude_list" - 512 BYTES, 3 ROWS
ARCHIVING DATABASE "DBA_INFO" TABLE "dba_userid" - 11,938 BYTES, 94 ROWS
ARCHIVING DATABASE "DBA_INFO" TABLE "dba_useridx" - 7,018 BYTES, 53 ROWS
ARCHIVING DATABASE "DBA_INFO" VIEW "LOBJTBL"
ARCHIVING DATABASE "DBA_INFO" VIEW "LOGTBL"
ARCHIVING DATABASE "DBA_INFO" VIEW "sqltbl"
ARCHIVING DATABASE "DBA_INFO" VIEW "summarytbl"
ARCHIVING DATABASE "DBA_INFO" TABLE "DB_DEF_ACCOUNT" - 41,353 BYTES, 439 ROWS
ARCHIVING DATABASE "DBA_INFO" TABLE "useridtab" - 658 BYTES, 0 ROWS
ARCHIVING DATABASE "DBA_INFO" MACRO "GENERATE_VIEW"
ARCHIVING DATABASE "DBA_INFO" VIEW "INDICES"
ARCHIVING DATABASE "DBA_INFO" TABLE "Parent_Allrights" - 7,072 BYTES, 48 ROWS
ARCHIVING DATABASE "DBA_INFO" MACRO "macro1"
ARCHIVING DATABASE "DBA_INFO" MACRO "MACRONODE2"
I need to get ARCHIVING DATABASE, the word that follows that and then continue with information when I see the word TABLE, VIEW or MACRO. Here's what I have started, please feel free to suggest any solution. But I cannot get the other lines.
Code:
awk '/ARCHIVING DATABASE/{x=$0;getline;print x" "$0}' tmp.txt | tr '"' -d | tr '-' -d | tr ',' -d | cut -d" " -f6-15 | sed 's!../../.... ..:..:..!!;s!BYTES!!;s!ROWS.*$!!;s! *! !g' > out.txt