I was trying to lookup the versions of libdb in the debian archives with something like that:

$ aptitude search '~S~ndev$(~nlibdb~(\d~|-~)!~v~rnative)'

which didn't work as expected so I changed the search pattern for 'digit or dash' to a (malformed?) bracket pattern

$ aptitude search '~S~ndev$(~nlibdb[[:digit:]-]!~v~rnative)'

which did the job.

Curious about the engine under the hood I tried backreferencing

$ aptitude search '~n~([[:digit:]]~)\1\>~rnative'

which also worked and led me to the conclusion that it must be GNU ERE.

So I have two questions now:

  1. Does aptitude use GNU EREs?
  2. Is there any way to get aptitude to accept PCREs?

I hope someone can clarify this for me.

  • Apparently aptitude does not understand character class \d , but you could use [0-9] or [[:digit:]], instead. – jarno Apr 11 '19 at 9:32
  • What is tne meaning of $( ... ) in command? – jarno Apr 11 '19 at 9:34

Well, man aptitude is full of lines like this:

(see the section “Search Patterns” in the aptitude reference manual)

There is no such section in the man page on my Debian and nor could I find it in the info page (which just gave me the same man page). Searching google found this, which explains that

Most textual searches (for package names, descriptions, etc) are performed using case-insensitive regular expressions. This means that you must backslash-escape regular expression metacharacters [12] in searches (for instance, to find “g++”, you should use the pattern “g\+\+”).

[12] Regular expression metacharacters include: “+”, “-”, “.”, “(”, “)”, “|”, “[”, “]”, “^”, “$”, and “?”. Note that some of these are also aptitude metacharacters, so if you want to type (for instance) a literal “|”, it must be double-escaped: “\~|”.

And "Regular expressions" are a broken link to a page called tao_regexps.

  • I know. The site you found is probably the best source out there. I use it often for a quick lookup of search patterns link. It's still vague on REs there. Anyway, thx for the reply. – Roger Aug 29 '13 at 19:49
  • @Roger you're welcome.Just so you know, the "standard" way of expressing thanks in the stack exchange network is to upvote an answer if it helped and accept it if it actually answers your question. – terdon Aug 29 '13 at 19:51
  • 1
    ps: on my system (mint/ubuntu) there's a copy of said site in /usr/share/doc/aptitude/README - I assume it's there on debian too – Roger Aug 29 '13 at 19:52
  • @Roger thanks, I did not know that. Oh and yes, that site is a little vague but there is nothing vague about BREs, just google "Basic Regular Expressions" or go through the gritty details here. They are one of the major known REGEX types and the one most commonly used by *nix programs. – terdon Aug 30 '13 at 2:33
  • Aptitude is not using POSIX Basic Regular Expressions. E.g '+' is not metacharacter in POSIX BRE, but is special in aptitudes patterns. – jarno Apr 11 '19 at 9:28

What is wrong with:

aptitude search '?version(CURRENT) ^libdb[1-9] ! -'

As simple as possible and as complex as needed.

Best Regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.