Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

cmd - How to read and print contents of text file line by line?

So, I have no clue on how to have CMD echo lines from a *.txt text file one at a time with a tiny delay to make it seem like it's processing.

Is this even possible with a batch alone?

I've tried doing research, but I can't find sufficient text manipulation to be able to do this, but I do know how to make a pause between each command and how to do loops.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Despite your question being off topic, I have decided to include this because, there are already two answers and it can be achieved using a single line.

From a batch file:

@For /F Tokens^=1*Delims^=]^ EOL^= %%A In ('Find /N /V ""^<"C:est.txt"') Do @Echo(%%B&>Nul PathPing 127.0.0.1 -n -q 1 -p 450

From the Command Prompt:

For /F Tokens^=1*Delims^=]^ EOL^= %A In ('Find /N /V ""^<"C:est.txt"') Do @Echo(%B&>Nul PathPing 127.0.0.1 -n -q 1 -p 1350

Both examples do not omit empty lines from your source file, C:est.txt, which can be changed as required.
I have used PathPing for the 'tiny delay', because it seems more controllable; to adjust the delay all you need to do is change the last number until you find your most pleasing output.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...