Here, you could use the word boundary operators: either the \b
from perl
or \<
, \>
from vi
both supported by apt
and aptitude
.
That matches at the transition between a word character and a non-word character, a word character being an alphanumeric character or underscore in that case. That wouldn't work for you in that you want to consider _
as a separator, but note that Debian packages don't have _
in their name, so that shouldn't be an issue if it's the package name you want to match against.
To search on package name only:
$ aptitude search '~n \bobs\b'
p obs-api - Open Build Service (api)
p obs-build - scripts for building RPM/debian packages f
p obs-plugins - recorder and streamer for live video conte
p obs-plugins:i386 - recorder and streamer for live video conte
p obs-plugins-dbgsym - debug symbols for obs-plugins
p obs-plugins-dbgsym:i386 - debug symbols for obs-plugins
p obs-productconverter - Open Build Service (product definition uti
p obs-server - Open Build Service (server component)
p obs-studio - recorder and streamer for live video conte
p obs-studio:i386 - recorder and streamer for live video conte
p obs-studio-dbgsym - debug symbols for obs-studio
p obs-studio-dbgsym:i386 - debug symbols for obs-studio
p obs-utils - Open Build Service (utilities)
v obs-webui -
p obs-worker - Open Build Service (build host component)
Because \b
is a word boundary, it also matches at the start of the subject, even though in that case obs
is not preceded by a separator character.
bash
, but the in the example ofapt-search ....
, it would actually beapt-search
doing to regular expression matching.apt
was simply an example. Just think ofapt-search obs | grep ¤
or more generallyX | egrep ¤
(or a more efficient way I'm not aware of). I'll modify my answer to reflect the general way.[[:punct:]]+
, though it looks no better than enumerating them ;-). But I think that you better use the\<
and\>
(start/end of word "zero-length assertions") which are supported by apt:apt-cache search '\<obs\>'
.