ubuntu split命令文件切割

本文介绍了如何使用Linux的split命令来切割大文件,并提供了详细的操作步骤。通过示例展示了如何按行数和文件大小进行切割,以及如何将切割后的文件重新组装。在切割时,文件被均匀地分配到多个小文件中,便于管理和查阅。组装文件时,可以灵活选择部分或全部文件合并。这对于处理大文件场景非常实用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Refrence

https://blog.bbskali.cn/394.html


有时会遇到文件比较大,无法查阅,需要切割才行;
命令参数:
split [选项] [要切割的文件] [输出文件名前缀]

  1. 首先查看文件大小
ls -lh
//目标文件
android@split:~/home/split$ ls -lh
总用量 3.9G
-rw-rw-r-- 1 android android 3.9G 1月 25 09:52 test.txt
  1. 切割,以a,b,c方式生成文件,小于500m的放到最后一个文件:
//行数切割
split -l 100 test.txt
//指定分割文件的大小为500M
split -b 500m test.txt log_

主要说一下指定分割文件的大小500m方式;

android@split:~/home/split$ split -b 500m test.txt log_
//通过ls -lh查看,非常均匀:
总用量 7.7G
-rw-rw-r-- 1 android android 500M 1月 25 18:20 log_aa
-rw-rw-r-- 1 android android 500M 1月 25 18:20 log_ab
-rw-rw-r-- 1 android android 500M 1月 25 18:20 log_ac
-rw-rw-r-- 1 android android 500M 1月 25 18:20 log_ad
-rw-rw-r-- 1 android android 500M 1月 25 18:20 log_ae
-rw-rw-r-- 1 android android 500M 1月 25 18:20 log_af
-rw-rw-r-- 1 android android 500M 1月 25 18:20 log_ag
-rw-rw-r-- 1 android android 442M 1月 25 18:20 log_ah
-rw-rw-r-- 1 android android 3.9G 1月 25 09:52 test.txt
  1. 组装文件,可以把自己想组装的文件进行组合:
//如想把log_aa log_ab两个文件组合到一起,test1是新生成的文件,而非原有文件:
android@split:~/home/split$ cat log_aa log_ab* > test1.text
//通过ls -lh查看完全ok;
总用量 1001M
-rw-rw-r-- 1 android android 1000M 1月 25 18:26 test1.text

如果想全部组装起来:

//直接log_它会以a,b,c方式组合到一起;
android@split:~/home/split ls -lh test2.text
-rw-rw-r-- 1 yuanjl yuanjl 1000M 1月
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值