天亦任我狂 天亦任我狂
关注数: 5 粉丝数: 0 发帖数: 28 关注贴吧数: 0
如何用批处理实现UNIX中的命令grep? 小弟刚刚批处理入门.有问题像各位高手请教!如何用批处理实现unix中的grep命令啊!以下是grep的-v.-c,-n,-i的实现.可是-l功能不会实现.即在多文件搜索匹配字符时,如何只显示含有匹配字符的文件的文件名啊!帮帮忙,告诉我怎么实现吧~谢谢啊!  @echo off  if "%1"=="" goto forhelp  if "%1"=="--help" goto help  set %var=find  goto findoperation  goto end  :forhelp  ::forhelp switch  echo Usage: grep [OPTION]... PATTERN [FILE]...  echo Try `grep --help' for more information.  goto end  :help  ::help switch  echo Usage: grep [OPTION]... PATTERN [FILE] ...  echo Search for PATTERN in each FILE or standard input.  echo Example: grep -i 'hello world' menu.h main.c  echo -v  显示所有不包含指定 string 的行。   echo -c  计算包含指定 string 的行并显示总数。   echo -n  将文件行号置于每行开头。   echo -i  指定搜索不区分大小写。   goto end  :findoperation  if "%1"=="" call %var%&goto end  if "%1"=="-v" set var=%var% /V&shift&goto findoperation  if "%1"=="-n" set var=%var% /N&shift&goto findoperation  if "%1"=="-i" set var=%var% /I&shift&goto findoperation  if "%1"=="-c" set var=%var% /C&shift&goto findoperation  set var=%var% "%1"&shift&goto findoperation  :end  ::the end of the .bat
如何用批处理实现UNIX中的命令grep! 小弟刚刚批处理入门.有问题像各位高手请教!如何用批处理实现unix中的grep命令啊!以下是grep的-v.-c,-n,-i的实现.可是-l功能不会实现.即在多文件搜索匹配字符时,如何只显示含有匹配字符的文件的文件名啊!帮帮忙,告诉我怎么实现吧~谢谢啊!  @echo off  if "%1"=="" goto forhelp  if "%1"=="--help" goto help  set %var=find  goto findoperation  goto end  :forhelp  ::forhelp switch  echo Usage: grep [OPTION]... PATTERN [FILE]...  echo Try `grep --help' for more information.  goto end  :help  ::help switch  echo Usage: grep [OPTION]... PATTERN [FILE] ...  echo Search for PATTERN in each FILE or standard input.  echo Example: grep -i 'hello world' menu.h main.c  echo -v  显示所有不包含指定 string 的行。   echo -c  计算包含指定 string 的行并显示总数。   echo -n  将文件行号置于每行开头。   echo -i  指定搜索不区分大小写。   goto end  :findoperation  if "%1"=="" call %var%&goto end  if "%1"=="-v" set var=%var% /V&shift&goto findoperation  if "%1"=="-n" set var=%var% /N&shift&goto findoperation  if "%1"=="-i" set var=%var% /I&shift&goto findoperation  if "%1"=="-c" set var=%var% /C&shift&goto findoperation  set var=%var% "%1"&shift&goto findoperation  :end  ::the end of the .bat
如何用批处理实现UNIX中的命令grep? 小弟刚刚批处理入门.有问题像各位高手请教!如何用批处理实现unix中的grep命令啊!以下是grep的-v.-c,-n,-i的实现.可是-l功能不会实现.即在多文件搜索匹配字符时,如何只显示含有匹配字符的文件的文件名啊!帮帮忙,告诉我怎么实现吧~谢谢啊!  @echo off  if "%1"=="" goto forhelp  if "%1"=="--help" goto help  set %var=find  goto findoperation  goto end  :forhelp  ::forhelp switch  echo Usage: grep [OPTION]... PATTERN [FILE]...  echo Try `grep --help' for more information.  goto end  :help  ::help switch  echo Usage: grep [OPTION]... PATTERN [FILE] ...  echo Search for PATTERN in each FILE or standard input.  echo Example: grep -i 'hello world' menu.h main.c  echo -v  显示所有不包含指定 string 的行。   echo -c  计算包含指定 string 的行并显示总数。   echo -n  将文件行号置于每行开头。   echo -i  指定搜索不区分大小写。   goto end  :findoperation  if "%1"=="" call %var%&goto end  if "%1"=="-v" set var=%var% /V&shift&goto findoperation  if "%1"=="-n" set var=%var% /N&shift&goto findoperation  if "%1"=="-i" set var=%var% /I&shift&goto findoperation  if "%1"=="-c" set var=%var% /C&shift&goto findoperation  set var=%var% "%1"&shift&goto findoperation  :end  ::the end of the .bat
1 下一页