linux中split函数用法,Linux split命令参数及使用方法详解
split即一款分割文件的小工具,可以根据设定的大小(如行数、字节数等)将一个文件等分成更小的文件。若文件大小超出文件系统支持的单文件最大值,或由于网络传输的限制,此时将大文件切分成同等大小的小文件,则可以很好的解决这些问题。
split help
[test@server ~]$ split --help
Usage: split [OPTION]... [INPUT [PREFIX]]
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default
size is 1000 lines, 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, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.
Report split bugs to bug-coreutils@gnu.org
GNU coreutils home page:
General help using GNU software:
For complete documentation, run: info coreutils 'split invocation'
使用
查看文件大小
[root@server ~]# ll -h
total 4.0K
-rw-r--r-- 1 root root 1.5K Mar 12 10:19 netstat.log.bz2
按bytes分割文件
[root@server ~]# split -d -b 1K netstat.log.bz2 netstat.log.bz2.
[root@server ~]# ll -h
total 12K
-rw-r--r-- 1 root root 1.5K Mar 12 10:19 netstat.log.bz2
-rw-r--r-- 1 root root 1.0K Mar 12 10:22 netstat.log.bz2.00
-rw-r--r-- 1 root root 500 Mar 12 10:22 netstat.log.bz2.01
测试分割后文件的完整性
[root@server ~]# bzip2 -v -t netstat.log.bz2.00
netstat.log.bz2.00: file ends unexpectedly
You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.
[root@server ~]# bzip2 -v -t netstat.log.bz2.01
netstat.log.bz2.01: bad magic number (file not created by bzip2)
You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.
合并分割后的文件
[root@server ~]# cat netstat.log.bz2.0[0-1] > netstat.log.recover.bz2
测试合并后文件的完整性
[root@server ~]# bzip2 -v -t netstat.log.recover.bz2
netstat.log.recover.bz2: ok
注意
-a 指定后缀名的长度。根据数字或字母,可以确定分割后的最大文件数
如果后缀为数字[0-9],则分割后最多有 10 ** ${suffix_length};
如果后缀为字母[a-z],则分割后最多有 26 ** ${suffix_length};
通常在使用split分割文件前,根据原文件大小,分割后大小,估算下分割后文件数量,以此确定合适的分割分割后缀和后缀长度,否则可能出现后缀不够用的情况。
查看要分割的文件大小
[test@server ~]$ wc netstat.log
302 1918 23945 netstat.log
按行分割文件
[test@server ~]$ split -a 2 -d -l 2 --verbose netstat.log netstat.log.
creating file `netstat.log.00'
... ...
creating file `netstat.log.99'
split: output file suffixes exhausted
该文件有302行,按2行一个文件进行分割,则会产生151(302/2)个文件。但在分割时,使用数字为后缀,长度为2,则最多能够产生 10 ** 2 = 100个文件,显然不够用。
linux中split函数用法,Linux split命令参数及使用方法详解相关推荐
- Linux top命令参数及使用方法详解
top命令 是用来监控 Linux 系统状况,比如cpu.内存的使用. top - 10:37:35 up 25 days, 17:29, 1 user, load average: 0.00, 0. ...
- linux中min函数用法,linux内核中的min、max函数
这些天为了整理一下前段时间看ldd3时所学的驱动知识,所以就去看了看usb驱动.不看不知道,一看吓一跳,里面有很多语法我发现用的太好了,不像我们平时那样写代码.里面写的代码真是太好了.然而要理解到里面 ...
- linux命令stat,Linux stat命令参数及使用方法详解
stat(status) 功能说明:获取文件的属性,例如大小,最后的修改时间等inode内容, stat以文字的格式来显示inode的内容. 语法:stat [文件或目录] 参数: # stat -- ...
- 编程实现linux中的who命令功能,Linux who命令简介及使用方法详解
玩蛇网推荐图文教程:python 列表 本文是关于Linux who命令简介及使用方法详解一文.如果你是一名系统管理员,可能需要需要在一个特定的时间点都有谁活跃在系统上.以便必须严密监视我们的服务器. ...
- python调用adb shell命令_Python之使用adb shell命令启动应用的方法详解
Python之使用adb shell命令启动应用的方法详解 一直有一个心愿希望可以用Python做安卓自动化功能测试,在一步步摸索中,之前是用monkeyrunner,但是发现对于控件ID的使用非常具 ...
- 怎么打开python shell_Python之使用adb shell命令启动应用的方法详解
一直有一个心愿希望可以用Python做安卓自动化功能测试,在一步步摸索中,之前是用monkeyrunner,但是发现对于控件ID的使用非常具有局限性,尤其是ID的内容不便于区分 具有重复性时,后面又发 ...
- win10装linux虚拟机contos,利用win10自带虚拟机hyper-v安装centos7方法详解
一.安装win10企业版自带虚拟机 hyper-v 1.控制面板-->程序和功能-->启用或关闭Windows功能 勾上 hyper-v 确定就ok了 2.安装成功后会发现在 左下角&qu ...
- python process 函数_Python Process创建进程的2种方法详解
前面介绍了使用 os.fork() 函数实现多进程编程,该方法最明显的缺陷就是不适用于 Windows 系统.本节将介绍一种支持 Python 在 Windows 平台上创建新进程的方法. Pytho ...
- linux getopt命令,Linux中getopt函数用法
最近做cache lab 用到了getopt函数, 用man 3 getopt查看了下用法, 做个总结. 描述:getopt函数是用来解析命令行参数的, 以'-'或'--'开头的参数为选项元素,除去' ...
最新文章
- JAVA实现变态跳台阶问题(《剑指offer》)
- c51单片机时钟c语言程序,89c51 C语言单片机 时钟程序
- 阿里钉钉陈航发布10亿“春雨计划”,推进企业级市场服务创新
- 启动oracle00119,oracle启动报ORA-00119错误
- mysql deadlock found when trying to get lock暴力解决
- python利用opencv标注bounding box
- 什么是pdi检测_汽车pdi检测是什么?如何知道新车做没做pdi
- 如何使用代理服务器更新系统_iPhone如何屏蔽iOS系统更新支持iOS12 iOS13
- java 二进制右移位_(九)二进制、位运算、位移运算符
- matlab模式识别大作业_史上最萌最认真的机器学习/深度学习/模式识别入门指导手册(二)...
- dhcp协议_什么是DHCP?总结DHCP优缺点和工作原理
- 深度学习:知识回收(神经网络模型:BPNN原理)
- 阿里云大学Linux学习路线图(学+测)重磅上线!
- video call BT audio音频流程
- VUE连接MQTT即时通讯
- android 联机游戏平台,游聚平台/街机平台/主机联网/街机对战平台/网络街机
- Python财务分析
- Java8 提供CompletableFuture来简化高并发异步处理编程
- 单片机要直接烧录程序,要如何做?
- HTTP头注入漏洞测试(X-Forwarded-for)
热门文章
- Java 并发编程之自定义线程池 ThreadPoolExecutor
- 怎么设置mysql 的权限_怎么设置SQL数据库用户权限
- python使用局部敏感性哈希算法,在海量数据中查询相似序列
- colorpix取色小工具_我发现一款神器!它集合了 60 多个超实用的工具
- Linux下更新libnss3的代码,yum安装firefox错误libnssutil3.s
- vue-router判断页面未登录时,自动跳转到登录页
- ES索引管理工具curator安装
- body-content取值的意义
- 执​行​o​r​a​c​l​e​函​数​的​四​种​方​法
- PHP curl get post通用类