How to use batch processing to find the text line with the largest number of characters
This article mainly shows you "how to use batch processing to find the lines of text with the largest number of characters". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn the article "how to use batch processing to find the lines of text with the largest number of characters".
The text a.txt is as follows:
Aaaaaaa aaaa bbbbbb ccccccccccc dddd
Aa aaaaaaa bbbbbbbb cccccccccc ddddddddddddd eeeeeee
Aaaaaaaaaaaa bbbbbbbbbbb cccccccccccccccccccc
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
Aaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbb
Aaaaaaaaa ccccccccc bbbbbbbbbbbbb ddddddddddddddddd
Using batch processing to find the lines with the largest number of characters (excluding spaces) in the text and output, it is obvious to copy the content to the clipboard code:
Aaaaaaaaa ccccccccc bbbbbbbbbbbbb ddddddddddddddddd
Request:
1 do not generate temporary files
2 simple code, high efficiency and good versatility
3 bonus points are still focused on thinking.
Shallow silence:
The code is as follows:
@ echo off
Setlocal Enabledelayedexpansion
Set nasty 0
For / f "delims="% I in (a.txt) do (
Set "ke=%%i"
Set KLBG: =!
Set massif 0
Call: 1
)
Echo wang%
Pause
Goto: eof
: 1
If not "! ke1:~%m%,1!" = "" set / a m+=1&goto 1
If m gtr n set n=%m%&set wang=%ke%
Goto: eof
Batman:
The code is as follows:
@ echo off
Set num=0
For / f "delims="% I in (a.txt) do set "str=%%i" & call,set "str=%%str: =%" & call: lp "% I"
Call,echo _ num%%% num% characters
Pause > nul&goto: eof
: lp
Set "str=%str:~1%" & set / a natives 1
If defined str goto lp
If n geq num% set "num=%n%" & set "_% num%=%~1"
Set "nasty 0"
The above is all the contents of the article "how to find the lines of text with the largest number of characters in batch processing". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!