← All commands
THE COMMAND REFERENCE

vdir

List files in the long format, like ls -l with escaped names.

Last updated

GNU

Implementation-level reference; examples are not certified for every installed version.

Overview

vdir lists files in the long format, the way ls -l -b does: permissions, owner, size, time and name. Like dir it exists for compatibility with other systems, and it takes the same options as ls.

Background

vdir is part of GNU coreutils; the GNU manual describes it as a version of ls with different defaults. macOS does not ship it, and the BusyBox 1.37.0 build used for this page has no such applet, so this page has only a GNU view.

Examples

List a folder in the long format; the first line is the total, then one line per file:

mkdir d && touch d/a d/b && vdir d | grep -c .

Show only the names, by taking the last field of each line after the total:

mkdir d && touch d/a d/b && vdir d | tail -n +2 | awk '{print $NF}'

Common mistakes

The long format changes between systems and with the locale, so do not parse it in a script. vdir is the same as ls -l, so most people just type ls -l. A name with spaces makes the last-field trick above fail.

Portability

This page covers GNU only. Use ls -l for anything that must run on macOS or BusyBox. The Common examples were executed on GNU coreutils 9.11 (see the development guide for the exact check).

About GNU vdir

GNU vdir is part of GNU coreutils, and this page's checks ran coreutils 9.11.

References

Original explanations, with upstream documentation for further reading. FreeBSD references are comparison material, not a claim of Apple version equivalence.