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

相关推荐
Moshow郑锴1 小时前
Ubuntu 26.04 中文输入法 : fcitx5+Rime中州韵引擎
linux·运维·ubuntu
莫名的好感°2 小时前
手机RAR解压怎么选?2026年二季度四款产品问答
服务器·网络·智能手机
qq_163135752 小时前
Linux 【04-more命令超详细教程】
linux
sevencheng7983 小时前
【ADB】adb命令行常用按键模拟代码
linux·adb·模拟按键,返回键,音量键
暗影天帝4 小时前
BPI-R3 Mini 刷 Yuzhii DHCPD U-Boot 教程
linux
小赖同学啊4 小时前
智能连接器集群化高可用生产方案
linux·运维·人工智能
wanghao6664554 小时前
DevOps 从入门到实践:构建高效交付流水线
运维·devops
qq_546937274 小时前
从“能用”到“超神”,DeepSeek++给网页版装上“大脑”和“手脚”,支持长期记忆、MCP工具与自动化任务!
运维·自动化
ZStack开发者社区4 小时前
基于AI Agent的ZCF API文档全链路自动化
运维·人工智能·自动化
Cinema KI4 小时前
Linux第一个系统程序-进度条
linux·服务器