File Listing

Modulok modulok at gmail.com
Mon Jan 10 23:14:14 UTC 2011


On 1/10/11, peter at vfemail.net <peter at vfemail.net> wrote:
>
> Is there one single-line command I can execute that will list every file in
> every directory on my FreeBSD box?  I've been fussing with the ls and du
> commands, but the output is never quite complete.

You might look into the 'tree(1)' command. It's a third party package
that can be installed as:

    # pkg_add -r tree

It has lots of flags to list files in various ways. By default it
lists all files in a tree-like format like this:

tree -a /etc
.
|-- X11
|-- aliases -> mail/aliases
|-- amd.map
|-- apmd.conf
|-- auth.conf
|-- bluetooth
|   |-- hcsecd.conf
|   |-- hosts
|   `-- protocols
|-- crontab
... and so on...

You can also list files with full paths without indents and such. See
man tree after its installed. Another example:

tree -aif /etc
/etc
/etc/X11
/etc/aliases -> mail/aliases
/etc/amd.map
/etc/apmd.conf
/etc/auth.conf
/etc/bluetooth
/etc/bluetooth/hcsecd.conf
/etc/bluetooth/hosts
/etc/bluetooth/protocols

There's also switches for how to handle symbolic links and staying on
one file system, depth limits, file limits, etc.
-Modulok-


More information about the freebsd-questions mailing list