免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2550 | 回复: 8
打印 上一主题 下一主题

如何将一个程序的输出,分成多个文件保存? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-01-04 15:43 |只看该作者 |倒序浏览
在unload的一张大表的时候,输出的文件远远大于2G,能不能写个shell,或者通过管道,
输出来的时候能分成多个文件?谢谢各位大侠!

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
2 [报告]
发表于 2006-01-04 16:14 |只看该作者
用dd,cslipt,均可

论坛徽章:
0
3 [报告]
发表于 2006-01-04 16:34 |只看该作者
同上

论坛徽章:
0
4 [报告]
发表于 2006-01-04 16:58 |只看该作者
具体怎么写呢?
如 sh unload.sh | csplit 吗?

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
5 [报告]
发表于 2006-01-04 17:02 |只看该作者
原帖由 winamp 于 2006-1-4 16:58 发表
具体怎么写呢?
如 sh unload.sh | csplit 吗?
/home/lee#csplit --help
Usage: csplit [OPTION]... FILE PATTERN...
Output pieces of FILE separated by PATTERN(s) to files `xx01', `xx02', ...,
and output byte counts of each piece to standard output.

长选项必须用的参数在使用短选项时也是必须的。
  -b, --suffix-format=FORMAT use sprintf FORMAT instead of %d
  -f, --prefix=PREFIX        use PREFIX instead of `xx'
  -k, --keep-files           do not remove output files on errors
  -n, --digits=DIGITS        use specified number of digits instead of 2
  -s, --quiet, --silent      do not print counts of output file sizes
  -z, --elide-empty-files    remove empty output files
      --help     显示此帮助信息并离开
      --version  显示版本信息并离开

Read standard input if FILE is -.  Each PATTERN may be:

  INTEGER            copy up to but not including specified line number
  /REGEXP/[OFFSET]   copy up to but not including a matching line
  %REGEXP%[OFFSET]   skip to, but not including a matching line
  {INTEGER}          repeat the previous pattern specified number of times
  {*}                repeat the previous pattern as many times as possible

A line OFFSET is a required `+' or `-' followed by a positive integer.

Report bugs to <bug-coreutils@gnu.org>.

论坛徽章:
0
6 [报告]
发表于 2006-01-04 17:18 |只看该作者
关键在于捕捉到输出,不是说怎么分.
sh unload.sh 将生成一个超过2G的大文件large_file,操作系统不支持,所以想通过管道来分,
最终成为如 large_file01,large_file02,large_file03...小于2G的多个文件.

论坛徽章:
0
7 [报告]
发表于 2006-01-04 20:02 |只看该作者
cut

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
8 [报告]
发表于 2006-01-05 02:07 |只看该作者
可用ulimit来限制生成文件的最大size,试一试吧

论坛徽章:
0
9 [报告]
发表于 2006-01-05 08:49 |只看该作者
用cslipt  cslipt是slipt的扩展
格式:
如果想分3个文件
cslipt 文件名 10 16  
拿个文件试试,没有行号可以用NR加上重定向
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP