There already exists command apt-cache dumpavail
which will list all available packages from all enabled repositories. Behind the scenes it actually reads from files stored in /var/lib/apt/lists/
directory (I've done strace
of the command, and that's what the output shows) . My guess would be that Gnome Software parses those very same files and organizes those into categories.
Problem is that the actual data has lines that start with Package:
for package names and Section:
to which they belong, but Section:
lines are not organized exactly the same as in Gnome Software. However, with a little bit of command line magic, we can come close to something like that. What I propose is a function
filter_sections()
{
apt-cache dumpavail | \
awk -v SEARCH="$@" '/^Package:/{ PKG=$0 }\
/Section:/ && $0~SEARCH {printf PKG" "$0"\n"}'
}
With that function we can list all packages by sections, for instance:
$ filter_sections web | head
Package: apache2 Section: web
Package: awstats Section: web
Package: curl Section: web
Package: heat-api Section: web
Package: heat-api-cfn Section: web
Package: heat-api-cloudwatch Section: web
Package: heat-common Section: web
Package: heat-engine Section: web
Package: javascript-common Section: web
Package: libapache2-mod-apparmor Section: web
The code itself is fairly simple: we pass on the output of apt-cache dumpavail
to awk
which stores every package name into a varialbe , and if the Section:
line also contains a string that we are matching, we will print both package name and the section.
As for listing the sections themselves, it's fairly easy as well
apt-cache dumpavail | awk '/Section:/' | sort | uniq
What is also nice about this approach is that some of the Sections
mention which repository the package belongs to, for example universe/python
or multiverse/web
. The function , however, will search for all and of them , but if so desired we can always filter with awk
even more
Best Answer
You can send those standard output and error messages to the null device, so that they don't show up in your terminal, e.g.
gedit test.html >/dev/null 2>&1