开发者

Regarding Shell Script

I have the below line in the unix shell script. I want to exclude test.jar in WEB-INF/lib being added to the CLASSPATH. How can i do it?

开发者_如何学Go
for file in WEB-INF/lib/*jar ; 

do


CLASSPATH=$CLASSPATH:$PWD/$file

done


for file in WEB-INF/lib/*jar;
do
if [ $file != "WEB-INF/lib/test.jar" ]; then
CLASSPATH=$CLASSPATH:$PWD/$file
fi
done

I have not tried it.


#!/usr/bin/bash
shopt -s extglob
for file in WEB-INF/lib/!(test).jar
do
  CLASSPATH="$CLASSPATH:$PWD/$file"
done


Something like

#!/bin/sh
...
PWD=`pwd`
for file in `ls $PWD/WEB-INF/lib | grep *.jar | grep -v test.jar`
   CLASSPATH=$CLASSPATH:$file
end


PWD=$(pwd)

for file in WEB-INF/lib/*jar ; do
    [ "$file" != "test.jar" ] && {
        CLASSPATH="${CLASSPATH}:${PWD}/${file}"
    }
done

The code between the braces is only entered if file is not 'test.jar' , tweak to suit your needs.


shopt -s extglob  
CLASSPATH=$CLASSPATH:$(ls !(test).jar|sed "s@^@$PWD/@"|tr "\n" ":"|sed 's/:$//')

Or

CLASSPATH=$CLASSPATH:$(ls !(genre).txt|awk '{$0="'$PWD'/"$0}1' ORS=":")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜