Skip to content

Category Archives: scripts

Testing inside a servlet with Ant, TestNG, and Groovy

In a previous post, I talked about how I run my TestNG unit/integration tests from within an EJB. The EJB implemented the old 2.0 standard, which meant that maintaining all of the configuration metadata was a continual effort sink. I recently moved it to simply use a servlet, which I should have done [...]

Grepping for classes in jars

There are more robust apps out there that find a Java class given a bunch of jars, but I mostly use this script. Usage is:

jargrep ClassName /scratch/a/dir/with/jars

Script:

#!/bin/bash
# usage: jargrep searchstring dir

for jar in `find $2 -name '*.jar' -type f`
do
echo $jar
jar tvf $jar | grep "$1"
done

I leave the echo of each [...]

Shell script for multi-file search and replace

A useful shell script for multi-file search and replace. Replace the .java with whatever extension you want

for i in `find . -name '*.java' -o -name '*.xml'`; do
cp $i $i.temp
sed -e 's/old text/new text/g' < $i.temp > $i
rm $i.temp
echo $i updated.
done