使用awk拆分大文件,使用正则表达式语法错误 [英] Split large file with awk, syntax error with regex

查看:65
本文介绍了使用awk拆分大文件,使用正则表达式语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个大文件,其中包含许多xml doc并置在一起.

Got a large file with lots of xml doc's concatenated together.

尝试使用以下命令拆分它们;

Trying to split them with the following command;

awk '/<\?xml/{g++} { print $0 > "ipg130101-"g".txt"}' ipg130101.xml

但请继续找回错误;

 context is
/<\?xml/{g++} { print $0 > >>>  "ipg130101-"g <<< ".txt"}
awk: illegal statement at source line 1

任何帮助,不胜感激!

推荐答案

一种解决方案是显式使用而不是(后者是MAc Os X上的默认值).

One solution is to use explicitly gawk instead of nawk (the latter is the default one on MAc Os X).

所以最后:

gawk '/<\?xml/{g++} { print $0 > "ipg130101-"g".txt"}' ipg130101.xml

这篇关于使用awk拆分大文件,使用正则表达式语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆