I'd like to search multiple packages at one using a regexp connecting pattern with logical or |
.
Assuming the two files /usr/lib/apache2/modules/httpd.exp
and /usr/lib/apt/apt.systemd.daily
exist:
$ sudo dpkg -S /usr/lib/apache2/modules/httpd.exp
apache2-bin: /usr/lib/apache2/modules/httpd.exp
$ sudo dpkg -S /usr/lib/apt/apt.systemd.daily
apt: /usr/lib/apt/apt.systemd.daily
why does apt-file search --regexp '/usr/lib/apache2/modules/httpd.exp|/usr/lib/apt/apt.systemd.daily'
only return
apache2-bin: /usr/lib/apache2/modules/httpd.exp
The solution is intended to be used for an optimization of the GNOME build tool jhbuild
. It should work an a large set of Ubuntu versions.
The problem is related to the source of files
apt-file
is matching. It uses the Contents files in /var/lib/apt/lists/, which do not contain the leading/
.So just skip the leading
/
in your regexp and you are fine. I also would recommend to escape dots\.
since `.* only means to match any character. In this case it might give you the expected results, but only because there are no other matches.The reason why it did work for
apache2-bin: /usr/lib/apache2/modules/httpd.exp
is becauseapt-file
is taking care of leading slashes and removes them in the search pattern.But this is only applied to the beginning of the pattern and it does not recognize the or operator and does not remove the leading slash from the second search part. The second search part
/usr/lib/apt/apt.systemd.daily
does not match because of the missing leading slash in the Contents file.Addendum
apt-file --regexp
is using Perl Regular Expressionsthe relevant part from man apt-file outlines the problem of this question in the BUGS, QUIRKS section