问题描述
我有一种情况,我想将每 5 条记录拆分为新文件 不知道如何开始使用这种方法,我需要动态创建拆分文件
例如下面是文件中的数据:
其中包含 11 条记录,脚本应将其拆分为 3 个不同的集合:如下所示
AA
BB
CC
DD
EE
FF
GG
HH
JK
LLL
HJ
预期输出:
abc1.txt -> first 5 records
abc2.txt -> next 5 records
abc3.txt -> last 1 records [ as it as only one records after splitting : count of file is odd]
我的脚本:
file_count=`awk 'END{print FNR}' demo.txt`
a=1
#Iterate the loop until a less than 10
while [ $a -lt $file_count ]
do
# Print the values
echo $a
if [ $a -eq 5 ]
then
fi
# increment the value
a=`expr $a + 1`
done < /d/demo.txt
任何使用 unix 或 python 的简单方法
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)