请教各位大侠,在txt文本行数未知的情况下,
sed能否按照每6万条数据来分割TXT文档呢?
sed能否按照每6万条数据来分割TXT文档呢?
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
D:\lxmxn\work\Other>(echo hello,world&echo.this is the second line of the output&echo.cn-dos.net&echo\OK,let's go&echo/Thanks a lot) | split -l 2我用的win32版本,并非DOS版本,应该是又DOS版本的。
D:\lxmxn\work\Other>dir /b x*
xaa
xab
xac
D:\lxmxn\work\Other>type x*
xaa
hello,world
this is the second line of the output
xab
cn-dos.net
OK,let's go
xac
Thanks a lot
D:\lxmxn\work\Other>split --version
split (textutils) 2.1
Written by Torbjorn Granlund and Richard M. Stallman.
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
D:\lxmxn\work\Other>
gawk "{n=int((NR-1)/100)+1;{print $0>>\"a_\"n\".txt\"}}" a.txt
@echo off & setlocal enabledelayedexpansion
set m=1
for /f "delims=" %%a in (a.txt) do (
if !n! GEQ 100 set n=0 & set/a m+=1
echo %%a>>a_!m!.txt
set/a n+=1
)
@echo off & setlocal enabledelayedexpansion
set m=1
for /f "delims=" %%a in ('findstr /n .* a.txt') do (
if !n! GEQ 100 set n=0 & set/a m+=1
for /f "tokens=1* delims=:" %%i in ("%%a") do echo.%%j>>a_!m!.txt
set/a n+=1
)