网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

批处理如何提取不同行上的内容-创新互联

这篇文章主要为大家展示了“批处理如何提取不同行上的内容”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“批处理如何提取不同行上的内容”这篇文章吧。

创新互联建站是一家专注于成都网站设计、网站建设、外贸网站建设与策划设计,雁江网站建设哪家好?创新互联建站做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:雁江等地区。雁江做网站价格咨询:13518219792
for instance:- 
for /f "delims=" %%a in (input.txt) do ... 
for /f "delims=" %%a in ('type input.txt') do ... 
for /f "delims=" %%a in ('more ^< input.txt') do ... 
However, only the last method (using the more command) will give consistent results across Windows NT, 2000, XP and 2003. The first method does not recognise unicode files. Also, the usebackq switch must be used if the input filename contains spaces. The second method, using the type command, also fails to recognise unicode files on Windows 2000, XP and 2003 if the input file does not begin with a bit order mark (BOM). 
In all the examples, assume the contents of of the file numbers.txt to be:- 
one 
two 
three 
four 
five 
six 
seven 
eight 
nine 
ten 
Displaying the first line 
This example prints one. 
@echo off & setlocal ENABLEEXTENSIONS 
set "first=" 
for /f "delims=" %%a in ('more ^< numbers.txt') do ( 
if not defined first set first=%%a 
) 
echo/%first% 
Displaying the first X lines 
This example prints one, two and three. 
@echo off & setlocal ENABLEEXTENSIONS 
set "lines=3" 
set i=-1 
set "ok=" 
for /f "delims=" %%a in ('more ^< numbers.txt') do ( 
set/a i+=1 & for /f %%z in ('echo/%%i%%') do ( 
if "%%z"=="%lines%" set ok=1 
) 
if not defined ok echo/%%a 
) 
Displaying the last line 
This example prints ten. 
@echo off & setlocal ENABLEEXTENSIONS 
for /f "delims=" %%a in ('more ^< numbers.txt') do set "last=%%a" 
echo/%last% 
Displaying the last X lines 
This example prints nine and ten. 
@echo off & setlocal ENABLEEXTENSIONS 
set "lines=2" 
for /f %%a in ('find/c /v "" ^< numbers.txt') do set/a skip=%%a-lines 
for /f "delims=" %%a in ('more/e +%skip% ^< numbers.txt') do ( 
echo/%%a 
) 
Displaying the Nth line 
This example prints three. Note that instead of using the more command's /e switch, the skip option could have been used with the for /f command, however, this fails is it is set to any number less than one. 
@echo off & setlocal ENABLEEXTENSIONS 
set LineNo=3 
set "line=" 
set/a LineNo-=1 
for /f "delims=" %%a in ('more/e +%LineNo% ^< numbers.txt') do ( 
if not defined line set "line=%%a" 
) 
echo/%line% 
Displaying the Nth line plus X number of lines 
This example prints five and six. 
@echo off & setlocal ENABLEEXTENSIONS 
set start=5 
set "lines=2" 
set/a i=-1,start-=1 
set "ok=" 
for /f "delims=" %%a in ('more/e +%start% ^< numbers.txt') do ( 
set/a i+=1 & for /f %%z in ('echo/%%i%%') do ( 
if "%%z"=="%lines%" set ok=1 
) 
if not defined ok echo/%%a 
)

以上是“批处理如何提取不同行上的内容”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


网页题目:批处理如何提取不同行上的内容-创新互联
网站链接:http://bjjierui.cn/article/jgjdh.html

其他资讯