按行数分割
- font size decrease font size increase font size
- Print Email
有个文件要处理,因为很大,所以想把它切成若干份,每份N行,以便并行处理。怎么搞呢?查了下强大的shell,果然有现成的工具--split。
下面记录下基本用法:
- split [-bl] file [prefix]
参数说明:
-b, --bytes=SIZE:对file进行切分,每个小文件大小为SIZE。可以指定单位b,k,m。
-l, --lines=NUMBER:对file进行切分,每个文件有NUMBER行。
prefix:分割后产生的文件名前缀。
示例:
假设要切分的文件为test.2012-08-16_17,大小1.2M,12081行。
1)
- split -l 5000 test.2012-08-16_17
生成xaa,xab,xac三个文件。
wc -l 看到三个文件行数如下:
5000 xaa
5000 xab
2081 xac
- 总计
2)
- split -b 600k test.2012-08-16_17
生成xaa,xab两个文件
ls -lh 看到 两个文件大小如下:
600K xaa
- xab
3)
- split -b 500k test.2012-08-16_17 example
得到三个文件,文件名的前缀都是example
ls -lh 看到文件信息如下:
500K exampleaa
500K exampleab
154K exampleac
Last modified onWednesday, 05 June 2013 09:01
( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0002 | 412304 | {main}( ) | .../index.php:0 |
2 | 0.0688 | 4262304 | Joomla\CMS\Application\SiteApplication->execute( ) | .../index.php:49 |
3 | 0.0688 | 4262304 | Joomla\CMS\Application\SiteApplication->doExecute( ) | .../CMSApplication.php:196 |
4 | 0.2644 | 11453320 | Joomla\CMS\Application\SiteApplication->dispatch( ) | .../SiteApplication.php:233 |
5 | 0.2657 | 11477648 | Joomla\CMS\Component\ComponentHelper::renderComponent( ) | .../SiteApplication.php:194 |
6 | 0.2668 | 11532976 | Joomla\CMS\Component\ComponentHelper::executeComponent( ) | .../ComponentHelper.php:377 |
7 | 0.2671 | 11560376 | require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ) | .../ComponentHelper.php:402 |
8 | 0.2786 | 11960008 | K2ControllerItem->execute( ) | .../k2.php:64 |
9 | 0.2786 | 11960008 | K2ControllerItem->display( ) | .../BaseController.php:710 |
10 | 0.2897 | 12610712 | K2ControllerItem->display( ) | .../item.php:78 |
11 | 0.2897 | 12610712 | K2ControllerItem->display( ) | .../controller.php:19 |
12 | 0.2943 | 12981752 | Joomla\CMS\Cache\Controller\ViewController->get( ) | .../BaseController.php:663 |
13 | 0.2952 | 13002120 | K2ViewItem->display( ) | .../ViewController.php:102 |
14 | 0.3657 | 15827592 | K2ViewItem->display( ) | .../view.html.php:742 |
15 | 0.3657 | 15827592 | K2ViewItem->loadTemplate( ) | .../HtmlView.php:230 |
16 | 0.3672 | 16000528 | include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ) | .../HtmlView.php:701 |
- Published in reaver
- Read 2688 times
( ! ) Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0002 | 412304 | {main}( ) | .../index.php:0 |
2 | 0.0688 | 4262304 | Joomla\CMS\Application\SiteApplication->execute( ) | .../index.php:49 |
3 | 0.0688 | 4262304 | Joomla\CMS\Application\SiteApplication->doExecute( ) | .../CMSApplication.php:196 |
4 | 0.2644 | 11453320 | Joomla\CMS\Application\SiteApplication->dispatch( ) | .../SiteApplication.php:233 |
5 | 0.2657 | 11477648 | Joomla\CMS\Component\ComponentHelper::renderComponent( ) | .../SiteApplication.php:194 |
6 | 0.2668 | 11532976 | Joomla\CMS\Component\ComponentHelper::executeComponent( ) | .../ComponentHelper.php:377 |
7 | 0.2671 | 11560376 | require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ) | .../ComponentHelper.php:402 |
8 | 0.2786 | 11960008 | K2ControllerItem->execute( ) | .../k2.php:64 |
9 | 0.2786 | 11960008 | K2ControllerItem->display( ) | .../BaseController.php:710 |
10 | 0.2897 | 12610712 | K2ControllerItem->display( ) | .../item.php:78 |
11 | 0.2897 | 12610712 | K2ControllerItem->display( ) | .../controller.php:19 |
12 | 0.2943 | 12981752 | Joomla\CMS\Cache\Controller\ViewController->get( ) | .../BaseController.php:663 |
13 | 0.2952 | 13002120 | K2ViewItem->display( ) | .../ViewController.php:102 |
14 | 0.3657 | 15827592 | K2ViewItem->display( ) | .../view.html.php:742 |
15 | 0.3657 | 15827592 | K2ViewItem->loadTemplate( ) | .../HtmlView.php:230 |
16 | 0.3672 | 16000528 | include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ) | .../HtmlView.php:701 |