# search ports



## polhallen (May 2, 2013)

I'm sorry for this (newbie) question but I come from the Linux world. I need to study this new world: freebsd FreeBSD 

I read the freebsd FreeBSD handbook on how to search a port:


```
cd /usr/ports
make search name=name_of_port
```
from the shell, how do I discover a relevant port?

I.e.: I looking for IDS but I don't known a name.

With Linux I search using `apt-cache search ids` and I see all package with IDS info/description. Using freebsd FreeBSD (in the shell) how do I search a package's info/description?


----------



## cpm@ (May 2, 2013)

From command line:

```
[CMD]# make search key=alpine | grep ^Port:[/CMD]
Port:	pico-alpine-2.00_1
Port:	alpine-2.00_3
Port:	pine-pgp-filters-1.8
[CMD]# whereis alpine[/CMD]
alpine: /usr/ports/mail/alpine
[CMD]# cat /usr/ports/mail/alpine/pkg-descr[/CMD]
Alpine is a screen-oriented message-handling tool for news, and POP, IMAP,
and local e-mail.  In its default configuration it offers a limited set of
functions geared toward the novice user, but it also has a large list of
optional "power-user" and personal-preference features.

Alpine's basic feature set includes:
	* View, Save, Export, Delete, Print, Reply and Forward messages.
	    Compose messages in a simple editor with word-wrap and a
	    spelling checker.  Messages may be postponed for later completion.
	* Selection and management of message folders.
	* Address book to keep a list of long or frequently-used
	    addresses.  Personal distribution lists may be defined.
	    Addresses may be taken into the address book from incoming mail
	    without retyping them.
	* New mail checking/notification occurs automatically (configurable).
	* On-line, context-sensitive help screens.

Alpine supports MIME (Multipurpose Internet Mail Extensions), an Internet
Standard for representing multipart and multimedia data in email.

WWW: http://www.washington.edu/alpine/
```

From browser:

[1] http://www.freshports.org.
[2] http://fbsdmon.org/ports.

P.S. @bkouhi's reply is correct.


----------



## bkouhi (May 2, 2013)

Try:

`make quicksearch [b]key[/b]=ids`
`make search [b]key[/b]=ids`

Alternatively, you can use http://www.freshports.org.


----------



## polhallen (May 2, 2013)

*O*k, an example:

`apt-cache search text editor`

```
alpine-pico - Simple text editor from Alpine, a text-based email client
aoeui - lightweight, unobtrusive, Dvorak-optimized text editor
beav - binary editor and viewer
[...]
```

Could alpine-pico be useful? Ok, I show the details:

`apt-cache show alpine-pico`

```
Package: alpine-pico
Priority: extra
Section: editors
Installed-Size: 700
Maintainer: Asheesh Laroia <asheesh@asheesh.org>
Architecture: i386
Source: alpine
Version: 2.00+dfsg-6+squeeze1
Depends: libc6 (>= 2.3.6-6~), libncurses5 (>= 5.7+20100313)
Filename: pool/main/a/alpine/alpine-pico_2.00+dfsg-6+squeeze1_i386.deb
Size: 371920
MD5sum: 12e14aa41990785cafae3844ddef3f97
SHA1: f62b2fdb64646d4cc3ba75c29ed1c0827c0e0d59
SHA256: 9184b1f2ee02d10a5953015492ec56a1d208a80db1b29b2eb676e65fb3a7e5df
Description: Simple text editor from Alpine, a text-based email client
 "pico" is a simple but powerful text editor.  It was originally the pine
 composer,  the editor used by the pine email client for writing email messages.
 .
[...]
```

*H*ow is the same thing sone using freebsd FreeBSD?

From the shell, I can't use a browser.

*T*hanks!


----------



## cpm@ (May 2, 2013)

```
[CMD]# make -C /usr/ports/ search key=alpine | grep -vE "B-deps|R-deps" | less[/CMD]
Port:   pico-alpine-2.00_1
Path:   /usr/ports/editors/pico-alpine
Info:   [Al]PIne's message COmposition editor and Pilot file manager
Maint:  c.petrik.sosa@gmail.com
WWW:    http://www.washington.edu/alpine/

Port:   alpine-2.00_3
Path:   /usr/ports/mail/alpine
Info:   Mail and news client descended from Pine
Maint:  c.petrik.sosa@gmail.com
WWW:    http://www.washington.edu/alpine/

Port:   pine-pgp-filters-1.8
Path:   /usr/ports/mail/pine-pgp-filters
Info:   Simple /bin/sh-based filters to use GnuPG with Alpine
Maint:  ports@FreeBSD.org
WWW:
```


----------



## bkouhi (May 2, 2013)

If you just want an one line description, try something like:

`find /usr/ports -name Makefile -exec grep -Hi -E '^COMMENT=.*text.*editor.*' {} \;`

Or:
`find /usr/ports -name Makefile -exec grep -Hi -e '^COMMENT=.*text.*' -e '^COMMENT=.*editor.*' {} \;`

Then simply `cd` to that port directory and read pkg-descr. But this is ugly :\

P.S. @cpu82's solution is much better.


----------



## phoenix (May 2, 2013)

Install ports-mgmt/psearch, read the man page, and carry on.


----------



## cpm@ (May 2, 2013)

@phoenix takes the cake :e


----------



## jnbek (May 2, 2013)

I was about to suggest `psearch` but I see that would be a redundant act of redundancy.


----------



## jb_fvwm2 (May 3, 2013)

```
cd /usr/ports/mail
find . -type f -name pkg-descr -exec /usr/local/bin/less {} \;
```
[I use `lookat` typically instead...]
This way takes a lot longer, but one can narrow down the search if one knows the category, and read a whole lot after just one command without having to change directories or even write anything down... One simply 'q' to exit each port, the next will be automatically read... and a ctrl-c to quit the command line [depending upon the program used to read each file...]

```
# or if one wants to just search a text file, continue the above command...
................................................../less {} \; | tee -a /tmp/mail.txt
```


----------



## segfault (May 3, 2013)

Thanks for the heads up on `psearch`. Never seen that before. When I am looking for a specific application such as alpine I would:

```
$whereis pico
alpine: /usr/ports/editors/pico
```
Then I `$ cat /usr/ports/editors/pico/pkg-desc` to get the description of it.

If I am 'shopping' for a new editor, I would just `cd` into the /usr/ports directory and start looking at the pkg-desc of anything that struck my fancy.


----------



## wblock@ (May 3, 2013)

If your system remains on full-time so the locate(1) database is built on weekends[1], it can be helpful for searching.  You can use partial names and still get results.  Filtering the output to only report files in /usr/ports helps restrict the output to ports:
`% locate pico | grep /usr/ports`

[1] Or you can rebuild the database manually.  Running `# /etc/periodic/weekly/310.locate` is easier for me than trying to remember the right manual form.


----------

