+ -
当前位置:首页 → 问答吧 → 每隔1000行插入一行:commit; 用单行命令怎么写? 单个文件有几百M.

每隔1000行插入一行:commit; 用单行命令怎么写? 单个文件有几百M.

时间:2011-03-01

来源:互联网

用  perl -pne 'if($. % 1001 == 0) {print "commit\n"}'   1.sql  


出错
Can't find string terminator "'" anywhere before EOF at -e line 1.

   正确的该怎么写?

作者: blackantt   发布时间: 2011-03-01

  1. perl -lpe 'print "xxx" if $. !=1 && ($. - 1) % 1000 == 0'
复制代码

作者: lululau   发布时间: 2011-03-01

perl -i -p -e 'if($. % 1000 == 0) {$_ = "$_commit\n"}'   1.sql

试试

作者: 珞水的大叔   发布时间: 2011-03-01

perl -pe 'BEGIN{$a=11}{if($.==$a){print ":commit;\n";$a+=10}}' file



QUOTE:
1
2
3
4
5
6
7
8
9
10
:commit;
11
12
13
14
15
16
17
18
19
20
:commit;
21
22
23
24
25
26
27
28
29
30
:commit;
31
32
33

作者: ziyunfei   发布时间: 2011-03-01