Linux split分割xls或csv文件

  • 文件名:test.xls

    split -a 2 -d -l 100 test.xls test

    -a 2:后缀是2位
    -d:后缀数字
    -l 100 :每100行一个文件
    test.xls:需要分割的文件名
    test:分割后的文件前缀

批量修改文件后缀
复制代码
for i in test*; do mv $i $i.xls; done
除了第一个文件有表头,其它分割出的文件均没有表头,需在文件第一行追加表头
复制代码
// 先查看文件表头
head -1 test00

// 删除文件表头
sed -i '1d' test00

// 追加表头
sed -i '1i name\tusername\tpassword' test00.xls
或
// 批量追加表头
for i in * ; do sed -i '1i name\tusername\tpassword' $i; done
如果Windows打开xls文件打开中文乱码,需转译编码格式
复制代码
iconv -futf8 -tgb2312 -otest_new.xls test.xls
// 或
iconv -futf8 -tgb18030 -otest_new.xls test.xls

Windows电脑打开csv或xls文件中文乱码问题(编码格式:UTF-8)

复制代码
printf '\xEF\xBB\xBF' > test01_new.xls
cat test01.xls >> test01_new.xls

或

sed -i '1s/^/\xef\xbb\xbf/' test*

EX: t_enterprise_all_1_code_addres_emails_web_url_telephones.csv文件是120G

split -a 2 (后缀是2位) -d(后缀数字) -b(文件大小) 4096MB t_enterprise_all_1_code_addres_emails_web_url_telephones.csv t_enterprise_all_1_code_addres_emails_web_url_telephones

split -a 2 -d -b 4096MB t_enterprise_all_1_code_addres_emails_web_url_telephones.csv t_enterprise_all_1_code_addres_emails_web_url_telephones

相关推荐
历程里程碑4 分钟前
Linux20 : IO
linux·c语言·开发语言·数据结构·c++·算法
郝学胜-神的一滴6 分钟前
深入浅出:使用Linux系统函数构建高性能TCP服务器
linux·服务器·开发语言·网络·c++·tcp/ip·程序人生
承渊政道9 分钟前
Linux系统学习【Linux系统的进度条实现、版本控制器git和调试器gdb介绍】
linux·开发语言·笔记·git·学习·gitee
技术路上的探险家10 分钟前
Ubuntu下Docker与NVIDIA Container Toolkit完整安装教程(含国内源适配)
linux·ubuntu·docker
代码AC不AC14 分钟前
【Linux】深入理解缓冲区
linux·缓冲区·标准错误
Doro再努力18 分钟前
【Linux操作系统12】Git版本控制与GDB调试:从入门到实践
linux·运维·服务器·git·vim
全栈工程师修炼指南29 分钟前
Nginx | stream content 阶段:UDP 协议四层反向代理浅析与实践
运维·网络·网络协议·nginx·udp
Lsir10110_37 分钟前
【Linux】进程信号(上半)
linux·运维·服务器
开开心心就好1 小时前
发票合并打印工具,多页布局设置实时预览
linux·运维·服务器·windows·pdf·harmonyos·1024程序员节
火车叼位1 小时前
脚本伪装:让 Python 与 Node.js 像原生 Shell 命令一样运行
运维·javascript·python