Reputation: 31
Could you please help command in Linux how to delete the .class file from inside a nested jar file
EX: A Jar Contains B.Jar (in side B.jar contains test.class) file
Now in above scenario i wanted to delete the test.class file from B.jar which is inside A.Jar .
Can you please help with linux command to perform this ?
Upvotes: 3
Views: 656
Reputation: 11
#!/bin/bash
#Example: /scanfix2.sh JndiLookup
if [ $# -lt 1 ] ; then
exit 1
fi
for i in `find . | grep -iE "(\.jar$|\.war$)"`;
do
c=`jar -tf $i | grep -i "\.jar" | wc -l`
if [ $c -ne 0 ]; then
echo "Scanning $i"
b=`basename $i`
f=`pwd`
rm -rf /tmp/$b
mkdir /tmp/$b
cp $i $i.bck
cp $i /tmp/$b/$b
cd /tmp/$b
jar -xf $b
rm $b
rm -rf scanfix_$b.txt
for j in `find .|grep -i /$1.class`;
do
mv $j $j.bck
echo Fixed $i $j >> scanfix_$b.txt
done
/scanfix2.sh $1 $i >> scanfix_$b.txt
cc=`cat scanfix_$b.txt|grep Fixed|wc -l`
if [ $cc -gt 0 ]; then
jar cf $b .
echo Nested $b [$cc fixes]
cat scanfix_$b.txt
cd $f
cp /tmp/$b/$b .
else
cd $f
rm $i.bck
fi
else
echo "Checking $2$i"
for j in `jar -tf $i|grep -i /$1.class`;
do
cp $i $i.bck
zip -q -d $i $j
echo Fixed $i $j
done
fi
done
Upvotes: 1