search

How to search multiple jar files for a string or pattern (shell script)

Here’s a Unix shell script that I use that search Java “jar” files for any type of pattern. You can use it to search for the name of a class, the name of a package, or any other string/pattern that will show up if you manually ran jar tvf on each jar file. The advantage of this script — if you’re a Unix, Linux, or Cygwin user — is that it will search through all jar files in the current directory:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

A map of “Why is [state] so ...” alvin February 6, 2017 - 9:57am

To create this graphic, someone Google’d all the queries for “Why is [state] so” (like, “Why is Illinois so”), and mapped the first Google auto-complete result onto each state. Makes me want to spend some time in the “haunted” states.

(They actually Google’d these queries in 2014. Makes me wonder what the current results look like.)

How to replace newline character with sed on Mac OS X (macOS) alvin November 12, 2016 - 3:57pm

I don’t have much time to explain this today, but ... if you want to see how to use the sed command on a Mac OS X (macOS) system to search for newline characters in the input pattern and replace them with something else in the replacement pattern, this example might point you in the right direction.

How to search for a string in all fields of every table in a MySQL database alvin May 5, 2016 - 4:55pm

This is pretty cool, if you want to search for a text string in all fields of all tables of a MySQL database, you can use phpMyAdmin to do this very easily. Here are the steps.

1) Select the desired database

The first step is to select the database you want to search. Don’t select a table — just select the database you want to search. (If you select a table you’ll get a different search form in Step 2.)

How to search the history of my Facebook posts alvin February 1, 2016 - 11:41am

Facebook FAQ: How do I search the history of my own posts?

I was just looking for an old Facebook post I thought I made about five months ago, and scrolling through the history of my posts was very painful. It seems like Facebook gets slower and slower the farther back in your history that you go. This made me wonder, is there any way to easily search through the history of my past Facebook posts?

While it’s not obvious, the answer is that yes, you can search your Facebook posts history, and here’s how you do it, at least as of February, 2016.

Google's RankBrain AI helps with 15% of all searches alvin October 26, 2015 - 12:41pm

According to this Bloomberg article, AI software named RankBrain helps Google with 15% of all searches.

How to search a MongoDB collection with Scala and Casbah alvin June 20, 2015 - 6:27pm

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 16.5, “How to search a MongoDB collection with Scala and Casbah.”

Problem

You want to find objects in your MongoDB collection using Scala and the Casbah driver.

Solution

Use the find* methods of the MongoCollection class to get the elements you want, specifically the find and findOne methods.

Solution to sed error message: “\1 not defined in the RE” alvin June 13, 2015 - 3:20pm

As a quick sed solution, if you get this “\1 not defined in the RE” error message when running a sed script:

$ sed -f sed.cmds c4.in.html > c4.out.html
sed: 2: sed.cmds: \1 not defined in the RE

the problem probably isn’t too bad. For me I usually get the error message when I forget to “escape” parentheses that I use in my search pattern. I usually write this, which is an error:

s/foo(.*)bar/\1/

when I need to write that sed command like this:

Mac OS X: ‘sed’ commands I use to clean MacDown HTML output alvin June 13, 2015 - 1:58pm

FWIW, this is the source code for a sed script I use on my Mac OS X system to convert HTML output generated by MacDown into a format I need. MacDown generates some extra “cruft” that I don’t need, so I use these sed commands to clean up that HTML output:

Scala: How to extract parts of a string that match a regex alvin May 30, 2015 - 5:10pm

Scala String FAQ: How can I extract one or more parts of a string that match the regular-expression patterns I specify?

Solution

Define the regular-expression patterns you want to extract from your String, placing parentheses around them so you can extract them as “regular-expression groups.” First, define the desired pattern:

val pattern = "([0-9]+) ([A-Za-z]+)".r

Next, extract the regex groups from the target string: