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

相关推荐
倔强的石头10615 小时前
【Linux指南】Makefile入门:从概念到基础语法
linux·运维·服务器
ajassi200015 小时前
linux C 语言开发 (七) 文件 IO 和标准 IO
linux·运维·服务器
程序猿编码15 小时前
基于 Linux 内核模块的字符设备 FIFO 驱动设计与实现解析(C/C++代码实现)
linux·c语言·c++·内核模块·fifo·字符设备
一只游鱼15 小时前
Zookeeper介绍与部署(Linux)
linux·运维·服务器·zookeeper
lllsure16 小时前
【Docker】存储卷
运维·docker·容器
wheeldown16 小时前
【Linux】 存储分级的秘密
linux·运维·服务器
不做菜鸟的网工16 小时前
Headscale 的部署方法和使用教程
运维
天天进步201516 小时前
掌握React状态管理:Redux Toolkit vs Zustand vs Context API
linux·运维·react.js
艾醒(AiXing-w)17 小时前
探索大语言模型(LLM):Ollama快速安装部署及使用(含Linux环境下离线安装)
linux·人工智能·语言模型
垚垚领先17 小时前
Kdump 文档 - 基于 kexec 的崩溃转储解决方案
linux