[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. @echo off
  2. for /l %%i in (1 1 100) do echo %%i
  3. pause>nul
  4. for /l %%i in (1 2 99) do echo %%i
  5. pause>nul
  6. for /f "tokens=1,2,3" %%i in ("bbs bathome.net") do (
  7. echo %%i
  8. echo %%j
  9. echo %%k
  10. )
  11. pause>nul
  12. type 2.txt
  13. echo.
  14. for /f "tokens=2" %%i in (2.txt) do echo %%i
  15. pause>nul
复制代码

TOP

新手,看不明白,还得多学啊

TOP

我是新手啊
试试看
1、批处理运行窗口显示1~100 这100 个数字;
@echo off
for /l %%i in (1 1 100) do echo %%i
pause>nul
2、批处理运行窗口显示 1、3、5.....99这50个数字;
@echo off
for /l %%i in (1 2 100) do echo %%i
pause>nul
3、将 bbs bathome.net (在同一行)分成三行显示在批处理运行窗口:
@echo off
for /f "tokens=1,2,3 delims= " %%a in ("bbs bathome.net") do (
echo %%a
echo %%b
echo %%c
)
pause>nul
4、先将以下内容保存到F:\test.txt

我是新手,那两题都不会做啊
砂石下的泉水,掘得越深,泉水会越清吗?

TOP

第4题答案

(1)。
@echo off
for /f "tokens=1-2*"  %%a in (f:/test.txt) do echo %%a %%b %%c
pause

(2)。

@echo  off
for /f   "tokens=2" %%a in (f:/test.txt) do echo  %%a  
pause

TOP

for /l %%a in (1 1 100) do @echo %%a
for /l %%a in (1 2 99) do @echo %%a
for %%a in (bbs bathome.net) do @echo %%a
for /f "tokens=1,2,3" %%a in (test.txt) do @echo %%a %%b %%c
for /f "tokens=2" %%a in (test.txt) do @echo %%a

TOP

1 for /l %%i in (1,1,100) do echo %%i
2 for /l %%i in (1,2,99) do echo %%i
3 for /f "tokens=1-3" %%i in ("bbs bathome.net") do (
echo %%i
echo %%j
echo %%k
)
4 ①for /f "delims=" %%a in (test.txt) do echo %%a  可以保证原格式。。。
   ②for /f "tokens=2" %%a in (test.txt) do echo %%a

[ 本帖最后由 claude55 于 2008-10-31 00:15 编辑 ]

TOP

第一题:
  1. for /l %%i in (1,1,100) do @echo %%i
复制代码
第二题:
  1. for /l %%i in (1,2,100) do @echo %%i
复制代码
第三题:
  1. @echo off
  2. set var=bbs bathome.net
  3. for /f "tokens=1-3 delims= " %%i in ("%var%") do (
  4. echo %%i
  5. echo %%j
  6. echo %%k
  7. )
复制代码
第四题:
1,
  1. for /f "delims=" %%i in (test.txt) do @echo %%i
复制代码
2,
  1. for /f "tokens=2" %%i in (test.txt) do @echo %%i
复制代码

TOP

第三题这样做,不可以吗?
\@echo off
for %%i in (bbs bathome.net) do echo %%i
pause

TOP

我的答案,请指教:
Title1.
  1. @echo off
  2. for /l %%a in (1 1 100) do echo/&echo %%a
  3. pause>nul
复制代码



Title2.
  1. @echo off
  2. for /l %%a in (1 2 100) do echo/&echo %%a
  3. pause>nul
复制代码



Title3.
  1. @echo off
  2. echo 处理前:bbs bathome.net
  3. echo\&echo/&echo.
  4. echo 处理后:
  5. for /f "tokens=1,2* delims= " %%a in ("bbs bathome.net") do echo %%a&echo.%%b&echo.%%c
  6. pause>nul
复制代码



Title4.
  1. @echo off
  2. type test.txt
  3. echo.&echo\
  4. for /f "tokens=2 delims= " %%a in (test.txt) do echo %%a&echo.
  5. pause>nul
复制代码

TOP

@echo off
echo.
echo start..............
for /l %%i in (1,1,100) do echo %%i
echo.
pause
for /l %%i in (1,2,100) do echo %%i
echo.
pause
for %%i in (bbs bathome.net) do echo %%i
echo.
pause
echo "1 2 3">test.txt
echo "4 5 6">>test.txt
echo "7 8 9">>test.txt
echo finished!
pause

TOP

1:
  1. @echo off
  2. for /l %%i in (1,1,100) do echo %%i
  3. pause>nul
复制代码

2:
  1. @echo off
  2. for /l %%i in (1,2,99) do echo %%i
  3. pause>nul
复制代码

3:
  1. @echo off
  2. set str=bbs bathome.net
  3. for %%i in (%str%) do (echo %%i)
  4. pause>nul
复制代码

4-1:
  1. @echo off
  2. for /f "tokens=*" %%i in (test.txt) do (echo %%i)
  3. pause>nul
复制代码

4-2
  1. @echo off
  2. for /f "tokens=2" %%i in (test.txt) do (echo %%i)
  3. pause>nul
复制代码

TOP

还好比较简单

TOP

echo off
set var=bbs bathome.net
echo %var%
for /f "tokens=1,2,3" %%i in ("%var%") do echo %%i &&echo.%%j &&echo.%%k
pause>nul

TOP

原帖由 pusofalse 于 2008-3-11 22:24 发表
1   for /l %%i in (1 1 100) do @echo %%i
2   for /l %%i in (1 2 100) do @echo %%i
3  for %%i in (bbs bathome.net) do @echo %%i
4  for /f "tokens=2" %%i in (f:\test.txt) do @echo %%i


对否。。

这个是对的!厉害,这么简单的语句就搞定了!

TOP

回复 2楼 的帖子 尊敬的老大们,小菜我有礼啦

你好,请问这个句中 for /L %%i in (1,1,100) do echo %%i   中的 /L  是什么意思,能否给个解释,
还有以下这几个 “tokens=1" 是什么意思,我看不懂。。
for /f "tokens=1 " %%a in ("%var%") do echo %%a
   for /f "tokens=2 " %%b in ("%var%") do echo %%b
   for /f "tokens=3 " %%c in ("%var%") do echo %%c
   pause>nul
谢谢。。。小弟我刚回这不多久。望能得前辈的指点

TOP

返回列表