侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

windows文件读取并输出行

2023-12-10 星期日 / 0 评论 / 0 点赞 / 122 阅读 / 850 字

batfor /f "tokens=1 delims= " %%i in (test.txt) do echo %%ivbsConst ForReading = 1dim objFSO,objF

bat

for /f  "tokens=1 delims= " %%i in (test.txt) do echo %%i

vbs

Const ForReading = 1dim   objFSO,objFile,strline   Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = objFSO.OpenTextFile("test.txt", ForReading)do   until   objFile.atendofstream           strline=objFile.readline           wscript.echo   strlineloop   objFile.close   set   fso=nothing 

powershell

$here = Split-Path $MyInvocation.MyCommand.Path$file = Get-Content "$here/test.txt" | %{     if($_ -notmatch "^/s*#+|^/s*$"){ $_.trim() }  }#loopforeach($line in $file){echo $line}

参考:

http://www.bathome.net/thread-32272-1-1.html

http://www.jb51.net/article/51606.htm

广告 广告

评论区