split command in linux

本文介绍了 Linux 下 split 命令的基本用法及如何避免文件名冲突的问题。通过设置不同的输出文件前缀,可以确保多进程同时使用 split 命令时,输出文件不会相互覆盖。

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

split

split is an useful command in linux to split files. I awlays use this command like this

split -d a.txt -l 1000000 

which split a.txt to output files of 1000 lines each and have numeric suffixes. For example, if a.txt have 50000000 lines, then this command will split a.txt to x01 x02 x03 x04 x05 .

But there is a situation that there are two files to split at the same time in a multi-process program, the two split command will generate the same output files and then they will cover each other. Obviously it will cause error. Now you can use split like this:

split -d a.txt -l 100000 a_

which will generate output files like a_00 a_01…. Then they will not conflict.

For more infomation about split, refer [^ask ubuntu] here

[^ask ubuntu] : http://askubuntu.com/questions/54579/how-to-split-larger-files-into-smaller-parts

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值