Home > OS >  Turn the sed command matches and replace invalid a newline character
Turn the sed command matches and replace invalid a newline character

Time:10-21

Is there such a text message:
11:00:33 2019-03-13. 403777 CST | gpadmin | template1 | p21310 | th687359968 | : : 1 | 27676 | 2019-03-13 11:00:33 CST | 0 | | cmd7 | 1 seg - | | | | sx1 | LOG: | | 00000 statement: SELECT typname, typlen FROM pg_type WHERE oids=25 | | | | | | SELECT typname, typlen FROM pg_type WHERE oids=25 | 0 | | postgres. C | 1616 |
2019-03-13 11:00:33. 407718 CST | gpadmin | template1 | p21310 | th687359968 | : : 1 | 27676 | 2019-03-13 11:00:33 CST | 0 | | cmd9 | seg - 1 | | | | sx1 | LOG: | 00000 | statement:
SELECT dbid, content, role, preferred_role, mode, and status,
The hostname, the address, the port, the datadir
The FROM pg_catalog. Gp_segment_configuration
The ORDER BY the content, preferred_role DESC | | | | | |
SELECT dbid, content, role, preferred_role, mode, and status,
The hostname, the address, the port, the datadir
The FROM pg_catalog. Gp_segment_configuration
The ORDER BY the content, preferred_role DESC
| 1616 | | 0 | | postgres. C
11:00:33 2019-03-13. 409371 CST | gpadmin | template1 | p21310 | th687359968 | : : 1 | 27676 | 2019-03-13 11:00:33 CST | 0 | | cmd11 | 1 seg - | | | | sx1 | LOG: | | 00000 statement: SELECT typname, typlen FROM pg_type WHERE oids=21 | | | | | | SELECT typname, typlen FROM pg_type WHERE oids=21 | 0 | | postgres. C | 1616 |
The 2019-03-13 11:00:34. 082752 CST | | | p21298 | th687359968 | | | | 0 | | | seg - 1 | | | | | LOG: | | 00000 database system is shut down | | | | | | | 0 | | xlog. C | 8245 |
The 2019-03-13 23:59:51. 858271 CST | | | p21455 | th877815776 | | | | 0 | | | seg - 1 | | | | | LOG: | 00000 | 3 rd party the error LOG:
Line=| | | | | | | | SysLoggerMain | syslogger. C | 705 |
The 2019-03-13 23:59:51. 858300 CST | | | p21455 | th877815776 | | | | 0 | | | seg - 1 | | | | | LOG: | 00000 | 3 rd party the error LOG:
164 | | | | | | | | SysLoggerMain | syslogger. C | 705 |
The 2019-03-13 23:59:51. 858345 CST | | | p21455 | th877815776 | | | | 0 | | | seg - 1 | | | | | LOG: | 00000 | 3 rd party the error LOG: | | | | | | | | SysLoggerMain | syslogger. C | 705 |
The 2019-03-13 23:59:51. 858479 CST | gpmon | gpperfmon | p18776 | th877815776 | [local] | | 2019-03-13 23:59:51 CST | | 0 con8378 | cmd1 | seg - 1 | | dx16920 | | sx1 | LOG: | 00000 | Planner produced plan: 0 | | | | | | insert into segment_history select * from _segment_tail; 58 | | | 0 | | orca. C

This is a log file, at present because of the illegal line problem, lead to cannot resolve; Now want to through the sed to remove the invalid newline, on condition that each line with "the 2019-03-13 23:59:51. 858300 CST" at the beginning of this date format that is the beginning of the effective records, not at the beginning of this format, considered before line didn't end and line breaks,

Through the sed, hope to be able to get content, each line is "the 2019-03-13 23:59:51. 858300 CST" date format at the beginning of a complete line, there will be no invalid line;
Thank you master,

CodePudding user response:

Can consider to go to all newline reoccupy date separated
 
The cat test. TXT | sed ": a; N; S/\ n//g; Ta "| sed 's/2019/\ n2019/g'
  • Related