0

I want to search several words in FreeBSD packages using pkg command

Example, if I want to search all packages with the words "web server" in the description, someone would try this:

pkg search web server

But it does not work. Neither with quotes.

2 Answers 2

0

Suspecting you want to search for both words you use grep:

pkg search web |grep server

Based on pkg documentation this command should work:

pkg -g search "web server"

You may add -i to make search case insensitive

9
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review Commented May 20, 2023 at 19:08
  • @JoepvanSteen, this provide the answer of the question: "How to search several words in pkg". The OP do not mention he/she want to do the entire search only in pkg. So it is an answer, sample, fast and short! Also it is not required to write "War and Peace" to answer clearly to the question and to provide valuable answer. Commented May 20, 2023 at 19:13
  • It's a question. I flagged it as low quality answer, feel free to edit and improve it. Commented May 20, 2023 at 19:16
  • @JoepvanSteen, and it provide answer: the example command give to OP the operation he/she search. Commented May 20, 2023 at 19:17
  • 1
    @somenxavier if you want a solution using just pkg, that should be clearly stated in the question.
    – Destroy666
    Commented May 22, 2023 at 8:10
0

Take a look at https://freshports.org, there is a very nice filtering system to specify what you are looking for.

To do this from the command line, you are looking for the -S flag and options.

By default, pkg searches on the pkg-name. Meaning, if you type pkg search webserver it will look for a package with webserver in the name. As you probably ran into, this cant find many webservers. Matter of fact, for me, it returned 0 results. The -S flag allows us to specify if we wish to search by pkg-name, description, comment, name, or origin.

Using this, a command of pkg search -S description "web server" returns WAY more info. More than I believe you are looking for. This will display the ENTIRE description for every pkg with web server in it. So lets say we want to search for all packages that are described as "web servers", but only return the names of those packages. We can apply an additional flag -L which can compact it to just the pkg name.

Below is a cleaner option, probably what you are looking for.

pkg search -S description -L name "web server"

NOTE: -S and -L are case-sensitive, refer to pkg help search command for more details.

If you run into issues, always always refer to the documentation and man pages!

I hope this helps and informs others as well.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .