2014-06-13 391 views
0

我有一個劇本.SH轉換.SH shell腳本文件爲.bat批處理文件

#!/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 

有人可以幫我將它轉換爲.BAT運行在Windows腳本。

問候, DH

回答

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文件相同的假設)

相關問題