Tacky Advanced Grepping

From time to time I find myself having to do some quick one off searches to find source code that may have been written already so I don’t have to reinvent the wheel.

In addition, you may remember in a previous blog post or if you have visited my GitHub that I wrote up a Recursive Java Decompiler to allow us to view source code for breakpointing, searching, and much more.

This in hand with the “tacky grepping” has allowed me to find solutions from methods other developers have written and/or usage examples similar to what I’m trying to achieve.

I titled this blog post tacky because I’m essentially piping a pipe of a pipe of a pipe of a pipe of a pipe which is definitely not recommended unless you like turning your computer into a dead potato.

But this is the solution for those of us that either don’t know regular expressions, remember them, or straight up just don’t want to learn them.

#Run in the background
grep -r -i --include \*.java "word1ImLookingFor" | grep -i "word2ImLookingFor" | grep -i -v 'import' > findings.out

#Run in separate Bash Window
#Grep Those Findings For Faster Filtering
grep -i "word3ImLookingFor" findings.out | grep -i -v "word1IdontWant" | grep -i -v "word2IdontWant" | grep -i -v "word3IdontWant" | grep -i "word4ImLookingFor"

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 )

Facebook photo

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

Connecting to %s