将.sh shellscript文件转换为.bat批处理文件

时间:2014-06-13 09:20:04

标签: batch-file

我有一个.sh脚本

#!/bin/sh

LOOK_FOR="codehaus/xfire/spring"

for i in `find . -name "*jar"`
do
  echo "Looking in $i ..."
  jar tvf $i | grep $LOOK_FOR > /dev/null
  if [ $? == 0 ]
  then
    echo "==> Found \"$LOOK_FOR\" in $i"
  fi
done

有人可以帮助我将其转换为在Windows上运行的.bat脚本。

此致 DH

1 个答案:

答案 0 :(得分:0)

@echo off
    setlocal enableextensions

    set "LOOK_FOR=codehaus/xfire/spring"
    for %%a in ("*.jar") do ( 
        echo Looking in %%a
        jar tvf "%%a" | find "%LOOK_FOR%" >nul && echo Found in %%a 
    )

当然假设您在路径中有jar.exe,当前文件夹包含.jar个文件(.sh文件中的相同假设)