系统集成Linux

linux 将大文件分成小文件

最近lvm磁盘老报错,message文件大的惊人,想找个办法将这个文件分成若干的小文件来查看。无意中发现这个神器-----split


例如将一个message文件分成前缀为message_ 的100个小文件,后缀为系数形式,且后缀为4位数字形式

先利用

wc -l message      获得message 文件一共有多少行

然后将结果除以100记过大概是81114;

然后用 split 命令



1

split -l 81114 messages messages_




将 文件message分成若干个小文件,每个文件81114 行(-l 81114 ),文件前缀为mesage_,系数不是字母而是数字(-d),后缀系数为四位数(-a 4)





1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

SPLIT(1)                         User Commands                        SPLIT(1)
NAME
       split - split a file into pieces
SYNOPSIS
       split [OPTION]... [INPUT [PREFIX]]
DESCRIPTION
       Output  fixed-size  pieces  of INPUT to PREFIXaa, PREFIXab, ...; default size is 1000lines, and
       default PREFIX is ‘x’.  With no INPUT, or when INPUT is -, read standard input.
       Mandatory arguments to long options are mandatory for short options too.
       -a, --suffix-length=N
              use suffixes of length N (default 2)
       -b, --bytes=SIZE
              put SIZE bytes per output file
       -C, --line-bytes=SIZE
              put at most SIZE bytes of lines per output file
       -d, --numeric-suffixes
              use numeric suffixes instead of alphabetic
       -l, --lines=NUMBER
              put NUMBER lines per output file
       --verbose
              print a diagnostic just before each output file is opened
       --help display this help and exit
       --version
              output version information and exit
       SIZE may be (or may be an integer optionally followed by) one of following: KB 1000, K1024,  MB
       1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.
AUTHOR
       Written by Torbjorn Granlund and Richard M. Stallman.
REPORTING BUGS
       Report split bugs to [email]bug-coreutils@gnu.org[/email]
       GNU coreutils home page:
       General help using GNU software:
       Report split translation bugs to
COPYRIGHT
       Copyright  ©  2010  Free  Software  Foundation, Inc.  License GPLv3+: GNU GPL version 3or later
       .
       This is free software: you are free to change and redistribute it.  There is NO WARRANTY, to the
       extent permitted by law.
SEE ALSO
       The  full documentation for split is maintained as a Texinfo manual.  If the info and split pro-
       grams are properly installed at your site, the command
              info coreutils 'split invocation'
       should give you access to the complete manual.


参与2

1同行回答

宇诺宇诺销售代表联想
想联系您直接购买SAP资料显示全部

想联系您直接购买SAP资料

收起
IT分销/经销 · 2022-09-25
浏览222

提问者

金刚狼
软件开发工程师传诚
擅长领域: 云计算服务器数据库
评论122

相关问题

相关资料

相关文章

问题状态

  • 发布时间:2013-08-08
  • 关注会员:1 人
  • 问题浏览:3881
  • 最近回答:2022-09-25
  • X社区推广