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

相关推荐
q***484116 小时前
Nginx中$http_host、$host、$proxy_host的区别
运维·nginx·http
橘子真甜~16 小时前
C/C++ Linux网络编程8 - epoll + ET Reactor TCP服务器
linux·服务器·网络
万变不离其宗_816 小时前
centos 手动安装redis
linux·redis·centos
_lst_16 小时前
linux进程状态
linux·运维·服务器
霍格沃兹测试开发学社-小明16 小时前
AI来袭:自动化测试在智能实战中的华丽转身
运维·人工智能·python·测试工具·开源
稚辉君.MCA_P8_Java17 小时前
Gemini永久会员 归并排序(Merge Sort) 基于分治思想(Divide and Conquer)的高效排序算法
java·linux·算法·spring·排序算法
wanderist.17 小时前
Linux使用经验——离线运行python脚本
linux·网络·python
MaisieKim_17 小时前
2025年企业文档管理系统全面评测报告
运维·数据库
biter008818 小时前
Ubuntu 22.04 有线网络时好时坏?最终解决方案
linux·网络·ubuntu
德育处主任18 小时前
『NAS』轻松获取群晖自带的壁纸
服务器·docker