Find Jars

Below is a tiny bash function to find jar file(s) containing a particular class:

function findjars(){
	for i in `find . -type f -iname "*.jar"`; do
		count=`jar tvf $i | grep -i $1 | wc -l`;
		if [ $count -ge 1 ]; then
			echo $i;
		fi;
	done;
}

I have added this function in .bashrc file in home directory and whenever I need to fnd a jar containing a particular class, I just type findjars classname (e.g. findjars BasicDataSource)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s