When I work with Java it can be handy to grep for a string in a JAR, so I have created an executable script called "jargrep".
#!/bin/bash # Greps a jar file for a string. if [ $1 ] ; then find . -name "*.jar" -a -exec bash -c "jar tvf {} | grep $1" \; -print else echo "Usage: jargrep [string]" echo " Example: jargrep \"string to grep for\"" fi
Create a text file called jargrep, copy the contents above, then run "chmod +x jargrep" to make it executable.
2 comments:
Nice idea. I thought it would grep for the file contents, but it greps for file names. -i option might be handy as well. If I learn to use it more, I will see if I'll tune it for my needs. Anyway, its' already pretty powerful. Thanks!
Good point. I'll see about expanding it.
Post a Comment