欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
從文本文件中讀取特定的行

>>This page shows how to read specific lines from a text file. There are many ways to have the for /f command read the input file, for instance:
這篇文章演示如何從文件中讀取特定的行.用for /f命令的多種變化方式可以達到該目的,例如:
---------------------------------for /f-----------------------------------------
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 ...
---------------------------------for /f-----------------------------------------

>>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).
然而,只有最后一種方法(用到more命令的)在windows nt,2000,xp和2003中能夠得到一致的結果。第一種方法,不能有效的識別unicode編碼文件,同時(shí),如果文件名含有空格時(shí),usebackq開(kāi)關(guān)必須打開(kāi)。第二種方法,用到type命令,同樣在windows nt,2000,xp和2003中,不能有效識別unicode編碼文件,同時(shí),要求輸入的文件內容不能以位序標志(BOM)開(kāi)頭.

>>In all the examples, assume the contents of of the file numbers.txt to be:
在如下所有的例子中,假設numbers.txt文件輸入以下內容:
----------------------numbers.txt--------------------------
one
two
three
four
five
six
seven
eight
nine
ten
----------------------numbers.txt--------------------------

JT_man注:以下代碼中的setlocal ENABLEEXTENSIONS都可以刪除,因為系統默認命令處理器擴展名是啟動(dòng)的。

>>Displaying the first line,This example prints one.
顯示第一行,打印第一行的例子如下:
------------------------1.bat------------------------------------------
@echo off & 
setlocal ENABLEEXTENSIONS 
set "first="
for /f "delims=" %%a in ('more ^< numbers.txt') do (
if not defined first set first=%%a
)
echo/%first%
pause>nul
------------------------1.bat-------------------------------------------

>>Displaying the first X lines,This example prints one, two and three.
顯示前幾行,打印第一,二,三行的例子如下:
------------------------123.bat-------------------------------
@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
)
pause>nul
------------------------123.bat-------------------------------

JT_man注:或者
------------------------123_2.bat------------------------------- 
@echo off
setlocal enabledelayedexpansion
set "lines=3"
rem 顯示前3行
set i=-1  
set "ok="
for /f "delims=" %%a in ('more ^< numbers.txt') do (
      set /a i+=1
      if !i!==%lines% set ok=1
      if not defined ok echo %%a
pause>nul 
------------------------123_2.bat------------------------------- 

>>Displaying the last line,This example prints ten.
顯示最后一行,打印第十行的例子如下:
------------------------10.bat--------------------------------------------
@echo off & setlocal ENABLEEXTENSIONS
for /f "delims=" %%a in ('more ^< numbers.txt') do set "last=%%a"
echo/%last%
pause>nul
------------------------10.bat--------------------------------------------

>>Displaying the last X lines,This example prints nine and ten.
顯示最后x行,打印第9,10行的例子如下:
------------------------lastx.bat-----------------------------------------------
@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 (
:: 或者 for /f "skip=%skip% delims=" %%a in ('more ^< numbers.txt') do ( 
echo/%%a
)
pause>nul
------------------------lastx.bat------------------------------------------------

>>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.
顯示第n行,打印第三行.
注意啟用more命令的擴展功能(/e)開(kāi)關(guān),同時(shí),ship選項過(guò)去常用于for /f命名中,但是當設定的數目小于實(shí)際值時(shí),將導致失敗
------------------------Nth.bat-----------------------------------------------
@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%
pause>nul
------------------------Nth.bat------------------------------------------------

>>Displaying the Nth line plus X number of lines,This example prints five and six.
顯示第n+x行,打印第5,6行的例子如下:
------------------------x+Nth.bat--------------------------------------------------
@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
)
pause>nul
------------------------x+Nth.bat----------------------------------------------------

JT_man注:或者
------------------------通用.bat-------------------------------------------------- 
@echo off
setlocal enabledelayedexpansion

set start=5
rem 開(kāi)始顯示的行號
set "lines=2"
rem 要顯示的行數

set/a i=-1,start-=1
set "ok=" 
for /f "skip=%start% delims=" %%a in ('more ^< numbers.txt') do (
      set/a i+=1
      if "!i!"=="%lines%" set ok=1
      if not defined ok echo/%%a
)
pause>nul 
------------------------通用.bat-------------------------------------------------- 

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
批處理(bat)命令學(xué)習的一些總結
BAT如何處理多余文本行數?
用手機當遙控:OE收件箱監控與主題提取工具【原創(chuàng )批處理】
bat 讀取文本內容用法
批處理學(xué)習17(for的使用-6)
命令行for示例
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久