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

TOP

  1. @echo off
  2. for /f %%i in ("bbs bathome.net") do echo %%i
  3. for /f "delims=.  tokens=1" %%i in ("bbs bathome.net") do echo %%i
  4. for /f "delims=. tokens=2" %%i in ("bbs bathome.net") do echo %%i
  5. pause>nul
复制代码
第三题也只能这样了\
中间的bathome 想单做一行太难了
我做不出来,只能做出bbs bathome net 或者 bbs bathome
还不错

TOP

心绪平和,眼藏静谧,继续加油

TOP

回答

第1题
for /f %%q in (1,1,100) do echo %%q
第2题
for /f %%e in (1,2,100) do echo %%e
第4题
for /l "tokens=2" %%d in (text.txt) do echo %%d

TOP

第3踢的回答

@echo off
for /f "delims=. tokens=1-3" %%i in ("bbs bathome.net") do echo %%i %%j %%k

TOP

回复 1楼 的帖子

  1. @echo off
  2. rem:第1题
  3. @echo off
  4. for /l %%i in (1 1 100) do echo %%i
  5. pause
  6. rem:第2题
  7. @echo off
  8. for /l %%i in (1 2 100) do echo %%i
  9. pause
  10. rem:第3题
  11. @echo off
  12. for /f "tokens=2 delims= " %%i in (test.txt) do echo %%i
  13. pause
  14. @echo off
  15. for /f "tokens=1-3 delims= " %%i in (test.txt) do echo %%i %%j %%k
  16. pause
复制代码

[ 本帖最后由 yihaode 于 2011-2-11 14:45 编辑 ]

TOP

1、批处理运行窗口显示1~100 这100 个数字;
  1. @echo off
  2. for /l %%i in (100 -1 1) do echo %%i
  3. pause
复制代码
2、批处理运行窗口显示 1、3、5.....99这50个数字;
  1. @echo off
  2. for /l %%i in (99 -2 1) do echo %%i
  3. pause
复制代码
3、将 bbs bathome.net (在同一行)分成三行显示在批处理运行窗口;
  1. @echo off
  2. for /f "delims=. tokens=1,2,3" %%i in ("bbs.bathome.net") do (
  3. echo %%i
  4. echo %%j
  5. echo %%k
  6. )
  7. rem 原题是 bbs bathome.net ,这个怎么提取呢,空格和“.”设置不了啊!
  8. pause
复制代码
4、先将以下内容保存到F:\test.txt
  1. @echo off
  2. for /f "tokens=2" %%i in (f:\test.txt) do  echo %%i
  3. pause
  4. rem 我怎么感觉第三题比第四题难多了……
复制代码

[ 本帖最后由 Hello123World 于 2011-1-27 11:38 编辑 ]

TOP

@echo off
for /L %%i in (1,1,100) DO echo %%i
pause
@echo off
for /L %%i in (1,2,100) DO echo %%i
pause
@echo off
for /f "tokens=2,5,8" %%i in (test.txt) DO echo %%i
pause
可惜不会做第3题

TOP

@echo off
for /i %%l in (1 1 100) do echo %%i
for /i %%l in(1 2 100) do echo %%i
for %%i in (bbs,bathhome,net) do echo %%i
type f:\test.txt
for /f "tokens=2" %%i in ("f:\test.txt") do type %%i

TOP

回复

第三题
@echo off
set str=bbs bathome,net
for /f "tokens=1-3 delims=, " %%i in ("%str%") do set  str1=%%i %%j %%k
for  %%i in (%str1%) do echo %%i
pause>nul
第四题
@echo off
for /f "tokens=1,2,3" %%i in (test.txt) do echo %%i %%j %%k
pause>nul
for /f "tokens=2"  %%i in (test.txt) do echo %%i

TOP

1.
  1. @echo off
  2. for /l %%i in (1,1,100) do echo %%i
  3. pause
复制代码
2.
  1. @echo off
  2. for /l %%i in (1,2,99) do echo %%i
  3. pause
复制代码
3.
  1. @echo off
  2. set a=bbs bathome.net
  3. for /f %%i in ("%a%") do echo %%i
  4. for /f "tokens=2 delims=+. " %%i in ("%a%") do echo %%i
  5. for /f "tokens=3 delims=+. " %%i in ("%a%") do echo %%i
  6. pause
复制代码
4.1
  1. @echo off
  2. for /f "delims=" %%i in (f:\test.txt) do echo %%i
  3. pause
复制代码
4.2
  1. @echo off
  2. for /f "tokens=2" %%i in (f:\test.txt) do echo %%i
  3. pause
复制代码

[ 本帖最后由 lzx 于 2010-11-3 01:48 编辑 ]

TOP

  1. 1.
  2. @echo off
  3. for /l %%I in (1,1,100) do echo %%I
  4. pause
  5. 2.
  6. @echo off
  7. for /l %%I in (1,2,99) do echo %%I
  8. pause
  9. 3.
  10. @echo off
  11. set var=bbs bathome.net
  12. echo %var%
  13. for /f "tokens=1,2,3 delims=. " %%I in ("%var%") do (
  14. echo %%I
  15. echo %%J
  16. echo %%K)
  17. pause
  18. 4.
  19. @echo off
  20. for /f "tokens=1-3" %%I in (F:\test.txt) do echo %%I %%J %%K
  21. for /f "tokens=2" %%I in (F:\test.txt) do echo %%I
  22. pause
复制代码

[ 本帖最后由 zsllq 于 2010-10-26 20:39 编辑 ]

TOP

@echo off
for /f "tokens=1-3 delims=. " %%a in ("bbs bathome.net") do echo %%a%%b
pause>nul

TOP

//第一题
@echo off
for /l   %%i in (1,1,100) do echo %%i
pause>nul

//第二题

@echo off
for /l   %%i in (1,2,99) do echo %%i
pause>nul

//第三题
@echo off
for /f "tokens=1-3 delims=. "  %%i in ("bbs bathome.net") do (
echo %%i
echo %%j
echo %%k
)
pause>nul
//第四题
@echo off
for /f "tokens=1-3 delims=. "  %%i in (test.txt) do (echo %%i  %%j  %%k)
pause

@echo off
for /f "tokens=2 delims=. "  %%i in (test.txt) do (echo %%i  )
pause
1

评分人数

    • Batcher: 请编辑自己的帖子,把代码放到code标签里面 ...PB -2

TOP

答案

  1. @echo off
  2. for /f "delims= tokens=1,2,3" %%i in (test.txt) do echo %%i
  3. pause
复制代码
本来以为这样执行的结果是只显示第一节也就是只显示147三个数字,没有想到竟全显示了,这是怎么回事?

TOP

返回列表