Searching within package names with apt-cache

September 25, 2012

When you run ‘apt-cache search’ it returns anything that has the search text in either the package title or the description.  What if you only want to search within the package name?  The following pattern will help you do that:

apt-cache search mysql | grep -P “^[^\s]*server[^\s]*”

In general it can be used to search within the first column of space delimited text.

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

%d bloggers like this: