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

相关推荐
宇钶宇夕9 分钟前
MODBUS RTU通信协议详解与调试指南
运维·程序人生·自动化
maomi_952612 分钟前
操作系统之EXT文件系统
linux·服务器
小羊Linux客栈2 小时前
自动化:批量文件重命名
运维·人工智能·python·自动化·游戏程序
伤不起bb3 小时前
MySQL 高可用
linux·运维·数据库·mysql·安全·高可用
whgjjim5 小时前
docker迅雷自定义端口号、登录用户名密码
运维·docker·容器
tmacfrank6 小时前
网络编程中的直接内存与零拷贝
java·linux·网络
瀚高PG实验室9 小时前
连接指定数据库时提示not currently accepting connections
运维·数据库
QQ2740287569 小时前
Soundness Gitpod 部署教程
linux·运维·服务器·前端·chrome·web3
淡忘_cx9 小时前
【frp XTCP 穿透配置教程
运维
qwfys2009 小时前
How to configure Linux mint desktop
linux·desktop·configure·mint