In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the batch processing of the use of for command what bug, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
1. About colons: when a line begins with:, use for / f "tokens=1* delims=:"% I in ('findstr / n. * test.txt') do echo.%%j to put:
Filter out
2. About the semicolon: findstr. * test.txt can fully display the lines starting with the semicolon, but it cannot be found when used in the for statement, and the parameter / n must be added.
It seems that the for statement ignores lines that begin with a semicolon as comments, as if it is not findstr's fault, while type, more and findstr that are not included in the for statement are all OK
Solutions to problems 1 and 2 are:
Slightly more complicated:
@ echo off
:: blank lines are not ignored
For / f "delims="% I in ('findstr / n. * test.txt') do (
Set "str=%%i"
Call set "str=%%str:*:=%%"
Call echo "str%%"
)
Pause
The simplest:
@ echo off
:: this code ignores blank lines
For / f "delims= eol=" I in (test.txt) do echo I
Pause
3. In the for extension,%% ~ si indicates that the path of the extension contains only short file names, but in the following testing process, it is found that this is not the case:
Test environment:
D:\ abcdefg hijk\ abcd efgh.txt
D:\ abcdefg hijk\ te st.txt
Test the code:
@ echo off
For / f "delims="% I in ('dir / a / b * .txt') do echo% ~ si
Pause
Test results:
D:\ ABCDEF~1\ ABCDEF~1.TXT
D:\ ABCDEF~1\ TEST~1.TXTtxt
Did you see the last record of the test results? Unexpectedly extended to TEST~1.TXTtxt!
Thank you for reading this article carefully. I hope the article "what is the bug of using for command in batch processing" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.