如何在bash中从特定应用程序数据库文件创建日志文件?
发布时间:2020-12-15 22:09:59 所属栏目:安全 来源:网络整理
导读:我有一个特定的应用程序数据库文件,如下所示: ?r vbc.vvc lin K$3?123456 ? ? P P P ;?é? ???????????????????????? ???? ? ???? ? P T X ? P 999999999 ?u q0 …a¤ ;?é?OverLimitLog ?? 06/27/2013 00:05:55 RS_A1_6 hijitso 183.49 OverLow ?? 06/27/2
我有一个特定的应用程序数据库文件,如下所示:
?r vbc.vvc lin K$3?123456 ? ? P P P ;?é? ???????????????????????? ???? ? ???? ? P T X ? P 999999999 ?u q0 …a¤ ;?é?OverLimitLog ?? 06/27/2013 00:05:55 RS_A1_6 hijitso 183.49 OverLow ?? 06/27/2013 00:16:30 qaser hijitso 993.08 hffvcgcf ?? 06/27/2013 00:18:46 yuikl hijitso 993.08 hffvcgcf ?? 06/27/2013 00:25:01 gcxsd hijitso 999.18 hffvcgcf ?? 06/27/2013 00:40:45 hgdrt sdfcdsfb 0.00 Normal ?? 06/27/2013 06:25:55 khuhukjmnj,l sdfcdsfa 13.13 hasfldkdgh ?? 06/27/2013 06:25:55 khuhukjmnj,l sdfcdsfc 13.13 hasfldkdgh ?? 06/27/2013 06:25:55 khuhukjmnj,l sdfcdsfb 13.13 hasfldkdgh ?? 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfa 0.00 Normal ?? 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfc 0.00 Normal fhfx 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfb 0.00 Normal ?? 06/27/2013 06:28:05 khuhukjmnj,l sdfcdsfa 10.79 hasfldkdgh ?? 06/27/2013 06:28:05 khuhukjmnj,l sdfcdsfc 10.79 hasfldkdgh ?? 06/27/2013 06:30:05 khuhukjmnj,l sdfcdsfc 9.38 hasfldkdgh ?? 06/27/2013 06:30:05 khuhukjmnj,l sdfcdsfb 9.38 hasfldkdgh ?? ?? ?? ?? ?? ?? 我想将它转换为这种格式: 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfc 0.00 Normal 我必须说,我的文件不是常规文本格式,并且在gedit中打开它时有一些不可读的字符,但emacs23可以打开这些文件. 解决方法
使用GNU awk,您可以执行以下操作:
$awk 'NR>1{print RS,$1,$2,$3,$4,$5,$6}' RS='fhfx' OFS='t' file fhfx 06/27/2013 00:05:55 RS_A1_6 hijitso 183.49 OverLow fhfx 06/27/2013 00:16:30 qaser hijitso 993.08 hffvcgcf fhfx 06/27/2013 00:18:46 yuikl hijitso 993.08 hffvcgcf fhfx 06/27/2013 00:25:01 gcxsd hijitso 999.18 hffvcgcf fhfx 06/27/2013 00:40:45 hgdrt sdfcdsfb 0.00 Normal fhfx 06/27/2013 06:25:55 khuhukjmnj,l sdfcdsfa 13.13 hasfldkdgh fhfx 06/27/2013 06:25:55 khuhukjmnj,l sdfcdsfc 13.13 hasfldkdgh fhfx 06/27/2013 06:25:55 khuhukjmnj,l sdfcdsfb 13.13 hasfldkdgh fhfx 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfa 0.00 Normal fhfx 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfc 0.00 Normal fhfx 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfb 0.00 Normal fhfx 06/27/2013 06:28:05 khuhukjmnj,l sdfcdsfa 10.79 hasfldkdgh fhfx 06/27/2013 06:28:05 khuhukjmnj,l sdfcdsfc 10.79 hasfldkdgh fhfx 06/27/2013 06:30:05 khuhukjmnj,l sdfcdsfc 9.38 hasfldkdgh fhfx 06/27/2013 06:30:05 khuhukjmnj,l sdfcdsfb 9.38 hasfldkdgh 或者如果你想要它更漂亮,你可以使用列 $awk 'NR>1{print RS,$6}' RS='fhfx' file | column -t fhfx 06/27/2013 00:05:55 RS_A1_6 hijitso 183.49 OverLow fhfx 06/27/2013 00:16:30 qaser hijitso 993.08 hffvcgcf fhfx 06/27/2013 00:18:46 yuikl hijitso 993.08 hffvcgcf fhfx 06/27/2013 00:25:01 gcxsd hijitso 999.18 hffvcgcf fhfx 06/27/2013 00:40:45 hgdrt sdfcdsfb 0.00 Normal fhfx 06/27/2013 06:25:55 khuhukjmnj,l sdfcdsfa 13.13 hasfldkdgh fhfx 06/27/2013 06:25:55 khuhukjmnj,l sdfcdsfc 13.13 hasfldkdgh fhfx 06/27/2013 06:25:55 khuhukjmnj,l sdfcdsfb 13.13 hasfldkdgh fhfx 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfa 0.00 Normal fhfx 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfc 0.00 Normal fhfx 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfb 0.00 Normal fhfx 06/27/2013 06:28:05 khuhukjmnj,l sdfcdsfa 10.79 hasfldkdgh fhfx 06/27/2013 06:28:05 khuhukjmnj,l sdfcdsfc 10.79 hasfldkdgh fhfx 06/27/2013 06:30:05 khuhukjmnj,l sdfcdsfc 9.38 hasfldkdgh fhfx 06/27/2013 06:30:05 khuhukjmnj,l sdfcdsfb 9.38 hasfldkdgh (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |