Skip to content

Instantly share code, notes, and snippets.

@trygvis
Created July 22, 2010 11:24
Show Gist options
  • Save trygvis/485855 to your computer and use it in GitHub Desktop.
Save trygvis/485855 to your computer and use it in GitHub Desktop.
Utility to create an index of all JAR files recursively
$ cat ~/bin/jarindex
#!/bin/bash
if [ -x /opt/csw/bin/gawk ]
then
awk=/opt/csw/bin/gawk
else
awk=awk
fi
if [ ! -x `which awk` ]
then
echo "Unable to execute awk: $awk" > /dev/stderr
exit 1
fi
if [ -r jarindex ]
then
cp jarindex jarindex.tmp
else
rm -f jarindex.tmp
fi
for jar in `find . -name '*.jar'|sort`
do
if [ jarindex -ot "$jar" ]
then
# continue
# else
echo Indexing: $jar
jar ft $jar | $awk -v jar=$jar '{printf("%s:%s\n", jar, $1)}' >> jarindex.tmp
fi
done
[ -r jarindex.tmp ] && mv jarindex.tmp jarindex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment