searching INDEX in .sh

Matthew Seaman m.seaman at
Sun Jul 25 09:13:00 UTC 2010

On 25/07/2010 03:58:29, Aiza wrote:
> I'm looking for a snippet of .sh type shell code that searches the
> /usr/ports/INDEX-8 file for dependents.
> Just a pointer to a script in the ports system that has this would be
> helpful.

grep 'dependency-name' /usr/ports/INDEX.8 | grep -v '^dependency-name'

If you don't want the whole INDEX line, add something like this to the
above to extract specific columns:

    | cut -d '|' -f 1

Note that you want the dependency package name, not the directory name
in the ports tree -- although most of the time they are the same, there
are some important packages where that isn't the case, eg.

     databases/mysql51-server   vs    mysql-server-5.1.48

Actually, all you want is sufficient leading prefix from the package
name to identify it uniquely, which usually, but not always, means you
don't need to include the version number part

This will include build dependencies as well as run- or lib-
dependencies: if that's not what you want, then use cut(1) to get rid of
the last two columns before passing the INDEX through grep(1)



Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP:     Ramsgate
JID: matthew at               Kent, CT11 9PW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 267 bytes
Desc: OpenPGP digital signature
Url :

More information about the freebsd-questions mailing list