1

Topic: Formatting pacman search results

Is there a way to format the output of a package search, preferably so that package names and descriptions are one a single line?

Having package names listed on one line and their descriptions listed on the following line makes filtering pacman search results useless. The package description may match my grep filter, but I don't know what to install because the package name isn't shown in the filtered output.

2

Re: Formatting pacman search results

Here's what I found to work:

pacman -Ss lisp | tr '\n' '\r' | sed 's/\r  /     /g' | tr '\r' '\n'

which gave me the following output:

extra/clisp 2.49-6       ANSI Common Lisp interpreter, compiler and debugger
extra/ecl 16.1.2-1       Embeddable Common Lisp
extra/sbcl 1.3.15-1 [installed]       Steel Bank Common Lisp
community/clojure 1.8.0-1.hyperbola1       LISP for the JVM
community/emacs-apel 10.8.20121102-2       A library for making portable Emacs Lisp programs.
community/owl-lisp 0.1.13-3       Simple purely functional lisp

The idea is that because package search with `pacman -Ss` outputs package descriptions on space-indented lines, we can replace/delete newlines followed by spaces while leaving other newlines unchanged. One problem that arises is that sed works on single lines. The workaround here (there are other, maybe better ones) is to replace newlines with carriage returns using ` tr '\n' '\r'`, then replace sequences of 'carrige return + some spaces' with sole spaces using `sed 's/\r  /     /g'` and finally convert the remaining carriage returns back to newlines using `tr '\r' '\n'`.
There're probably dozens of other ways to do it.

Btw, depending on your task all this might not be needed, since pacman -Ss already searches the descriptions and it can be used with regexps smile

3

Re: Formatting pacman search results

koszko wrote:

Here's what I found to work:

pacman -Ss lisp | tr '\n' '\r' | sed 's/\r  /     /g' | tr '\r' '\n'

Thank you!