windows 在批处理文件编程中使用“for”循环显示前 N 个自然数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3733883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:16:18  来源:igfitidea点击:

Using a 'for' loop in batch file programming to display the first N natural numbers

windowsloopswindows-xpbatch-filefor-loop

提问by Sarika.S

I would like to mainly know the working of a forloop. For this I think a small sample program will be helpful to me. So what is a simple program to display the first N natural numbers?

我想主要了解一个for循环的工作原理。为此,我认为一个小示例程序会对我有所帮助。那么显示前N个自然数的简单程序是什么?

回答by Ramon Araujo

If you are talking about Windows batch programming here you have a natural numbers generator:

如果你在这里谈论 Windows 批处理编程,你有一个自然数生成器:

for /L %i IN (0,1,9) do @echo %i

Other helpful links to deal with files and so on:

处理文件等的其他有用链接:

If you are talking about GNU Linux/Unix bash scripting you can go to:

如果你在谈论 GNU Linux/Unix bash 脚本,你可以去:

Hope that helps,

希望有所帮助,