[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#961411: apt search -- output NOT grepable



On 5/24/20, Leszek Dubiel <leszek.dubiel@dubielvitrum.pl> wrote:
> Package: apt
> Version: 1.8.2.1
> Severity: normal
>
> I've completely switched to using "apt" for all debian package management.
> I'm fine with the "apt" tool, it fits all my needs except one... serarching.
>
> For example I look for package to read/write JSON data in perl. In old days
> I used the command "apt-cache search" like this:
>
> 	leszek@len530:~$ apt-cache search perl | egrep JSON | egrep -i data
>
> and the result was simple:
>
> 	libjson-perl - module for manipulating JSON-formatted data
> 	libjson-xs-perl - module for manipulating JSON-formatted data
> (C/XS-accelerated)
> 	libcatmandu-importer-getjson-perl - load JSON-encoded data from a server
> using a GET HTTP request
> 	libjson-pp-perl - module for manipulating JSON-formatted data (Pure Perl)
> 	libjson-validator-perl - module to validate data against a JSON schema
> 	libtest-deep-json-perl - Test::Deep plugin for comparing JSON data
> 	libtest-json-perl - module for testing JSON data
>
>
> Because "apt search" (not "apt-cache search", just "apt") shows each package
> on two lines, then grepping results is not possible.

You can use awk to put the lines together and then grep:

$ apt search perl | awk -v RS="" '{gsub("\n",""); print $0}' | grep
JSON | grep -i data

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libcatmandu-importer-getjson-perl/oldstable 0.50-1 all  load
JSON-encoded data from a server using a GET HTTP request
libjson-perl/oldstable 2.90-1 all  module for manipulating JSON-formatted data
libjson-pp-perl/oldstable 2.27400-1 all  module for manipulating
JSON-formatted data (Pure Perl)
libjson-validator-perl/oldstable 0.92+dfsg-1 all  module to validate
data against a JSON schema
libjson-xs-perl/oldstable 3.030-1 i386  module for manipulating
JSON-formatted data (C/XS-accelerated)
libtest-deep-json-perl/oldstable 0.03-1 all  Test::Deep plugin for
comparing JSON data
libtest-json-perl/oldstable 0.11-2 all  module for testing JSON data

Regards,
Lee


Reply to: