簡體   English   中英

Windows 批處理腳本:Findstr output:過濾器 substring

[英]Windows batch script : Findstr output : Filter substring

我有一個腳本:

C:\"Program Files (x86)"\Dell\"Command Configure"\X86_64\cctk advsm --report=All | findstr /c:"Current speed" >> %LOG_FILE_NAME%

這給出了以下 output:

Current speed                : 3101 rpm

我只需要實際值“3101”而不是整行。 我怎樣才能得到這個?

for循環用於此:

for /f "tokens=3* delims=: " %%i in ('"%programfiles(x86)%\Dell\Command Configure\X86_64\cctk" advsm --report=All ^| findstr "Current speed"') do (echo %%i)>>%LOG_FILE_NAME%

未經測試的想法,但如果您首先報告您想要的值,可能會更簡單!

@For /F "Tokens=4" %%G In ('^""%ProgramFiles(x86)%\Dell\Command Configure\x86_64\cctk.exe" Advsm --Report^=C^"') Do >>"%LOG_FILE_NAME%" @Echo %%G

如果C不是您想要的 output ,那么您必須使用 Report=All 並搜索您的行。 您可以為此使用 find.exe:

@For /F "Tokens=4" %%G In ('^""%ProgramFiles(x86)%\Dell\Command Configure\x86_64\cctk.exe" Advsm --Report^=All ^| %SystemRoot%\System32\find.exe "Current speed"^"') Do >>"%LOG_FILE_NAME%" @Echo %%G

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM