# pkg show category



## antolap (Dec 16, 2017)

How to list all packages in a category?

for example, If you haven't ports installed, how to list all packages within ftp category ?


----------



## talsamon (Dec 16, 2017)

```
pkg search -o filezilla
ftp/filezilla                  Fast and reliable cross-platform FTP, FTPS, and SFTP client
ftp/libfilezilla               C++ library for building platform-independent programs
```

Look in`pkg help search`.


----------



## talsamon (Dec 16, 2017)

```
pkg version -o |grep firefox
www/firefox                        =
```

(I have filezilla not installed)


----------



## antolap (Dec 16, 2017)

I have made a mistake and changed the question:

for example if you want to list all packages in www category using `pkg`?
how to do without going to /usr/ports/www ?


----------



## talsamon (Dec 16, 2017)

`pkg query "%o" | grep x11`


----------



## talsamon (Dec 16, 2017)

`pkg help help` lists you all commands.`pkg help command` shows you a list of parameters of each command.


----------



## antolap (Dec 16, 2017)

`pkg query "%o" |grep www`
33 lines

If I do `ls /usr/ports/www` I see tons of packages


----------



## talsamon (Dec 17, 2017)

It only shows the installed packages.
I have ports-mgmt/psearch installed.

```
psearch -c www|wc -l
    3486
```
`wc -l` counts the lines.
Onyl show the entries: `psearch -c category`.


----------



## antolap (Dec 17, 2017)

talsamon said:


> I have ports-mgmt/psearch installed.



yes, but `psearch` looks into /usr/ports/ so you must have ports installed


----------



## talsamon (Dec 17, 2017)

Sorry, was wrong, `psearch` finds all e.g.  letters like www. Not only the categories.
`pkg search -o www/`  should do it.


----------



## tobik@ (Dec 17, 2017)

Use pkg-rquery(8) instead: `pkg rquery '%C %n-%v' | awk '/^www / { print $2 }'`. There maybe duplicate entries in the output because of virtual categories.


----------



## antolap (Dec 17, 2017)

Ok thanks!

last question:
how to show all categories using pkg?
I have tried with `pkg rquery '%C' | sort -u`, it works but result are not equal to directories in /usr/ports/
other ways to get categories list?


----------



## talsamon (Dec 17, 2017)

What you mean with "using pkg".  /usr/ports has a lot  of subdirectories like files/ or Mk/ etc.


----------



## antolap (Dec 17, 2017)

using this command `pkg rquery '%C' | sort -u` I see for example zope, which is not in /usr/ports


----------



## tobik@ (Dec 17, 2017)

antolap said:


> using this command `pkg rquery '%C' | sort -u` I see for example zope, which is not in /usr/ports


Yes, zope is a virtual category. There is no corresponding ports directory but ports/packages are still classified as belonging to it.

Try this: `pkg rquery '%o' | cut -d/ -f1 | sort -u`


----------



## antolap (Dec 17, 2017)

Ok thanks


----------



## antolap (Dec 17, 2017)

One moment:
`# pkg search filezilla
filezilla-3.24.0_2             Fast and reliable cross-platform FTP, FTPS, and SFTP client
..

# pkg search -o filezilla
ftp/filezilla                  Fast and reliable cross-platform FTP, FTPS, and SFTP client
...`

Using `-o`, how to show also the version of the package?


----------



## obsigna (Dec 17, 2017)

how about:

`sqlite3 -list /var/db/pkg/repo-FreeBSD.sqlite 'SELECT version FROM packages WHERE name="filezilla";'`

The above command shows the version in the repository while the following command shows the installed version:

`sqlite3 -list /var/db/pkg/local.sqlite 'SELECT version FROM packages WHERE name="filezilla";'`


----------



## talsamon (Dec 17, 2017)

```
pkg query "%o %v" firefox
www/firefox 57.0.2,1
```


----------

