dirx
List directory contents in columns, whether or not the output is a terminal.
Mirrors GNU dir. Run it as dirx, or as gnux dirx.
Synopsis
dirx [OPTION]... [FILE]...GNU reference
Description
dirx is lsx -C -b: it lists each FILE, or the current directory, exactly as lsx does and takes every lsx option, but arranges the names in columns even when the output is piped or redirected (80 columns wide then, or -w COLS), and writes unprintable characters in names as backslash escapes (\n, \t, \ooo) so that every name fits on one line, and never prints '?' for one unless -q is given. An option that picks a format (-l, -1, -x, -m, --format) or a quoting style (-N, -Q, --quoting-style, or the QUOTING_STYLE variable) replaces those defaults. Diagnostics and exit statuses are lsx's, prefixed with dirx.
Permissions
Listing a directory needs read permission on it; examining its entries (-l, -s, -i, -F, --color, sorting by time or size) also needs search permission. Nothing is ever modified.
Use cases
- Getting a compact column listing in a log or a file, where
lsxprints one name per line. - Listing a directory the way Windows users expect a dir command to work.
- Seeing names with newlines or tabs in them as escapes rather than broken lines.
- Keeping a script's listing the same whether or not it runs in a terminal.
- Comparing directory contents side by side in a narrow terminal with
-w.
Flags
-x, --across list entries by lines instead of by columns
-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
-u, --atime with -lt: sort by, and show, access time; with -l: show access time and sort by name; otherwise: sort by access time, newest first
--author with -l, print the author of each file
--block-size SIZE with -l, scale sizes by SIZE when printing them; e.g., '--block-size=M'
-F, --classify append indicator (one of */=@|) to entries
--color WHEN[="always"] color the output WHEN: 'always' (the default when WHEN is omitted), 'auto', or 'never'
--color-scale WHICH[="all"] color WHICH columns on a gradient by value: 'all' (the default when WHICH is omitted), 'size', 'age' or 'none'
-C, --columns list entries by columns
-m, --commas fill width with a comma separated list of entries
-c, --ctime with -lt: sort by, and show, ctime (time of last change of file status information); with -l: show ctime and sort by name; otherwise: sort by ctime, newest first
-L, --dereference when showing file information for a symbolic link, show information for the file the link references rather than for the link itself
-H, --dereference-command-line follow symbolic links listed on the command line
-d, --directory list directories themselves, not their contents
-D, --dired generate output designed for Emacs' dired mode
-b, --escape print C-style escapes for nongraphic characters
--file-type likewise, except do not append '*'
--format WORD across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C (WORD)
--full-time like -l --time-style=full-iso
--git with -l, print each file's git status (staged, then unstaged)
--git-ignore do not list entries that .gitignore rules exclude
--group-directories-first group directories before files; any use of --sort=none (-U) disables grouping
--header with -l, print a row naming each column
--help display this help and exit
--hide PATTERN do not list implied entries matching shell PATTERN (overridden by -a or -A)
-q, --hide-control-chars print ? instead of nongraphic characters
-h, --human-readable with -l and -s, print sizes like 1K 234M 2G etc.
--hyperlink WHEN[="always"] hyperlink file names WHEN: 'always' (the default when WHEN is omitted), 'auto', or 'never'
--icons WHEN[="always"] show an icon (Nerd Font) before each name WHEN: 'always' (the default when WHEN is omitted), 'auto', or 'never'; GNUX_ICONS sets the default
-I, --ignore PATTERN do not list implied entries matching shell PATTERN
-B, --ignore-backups do not list implied entries ending with ~
--indicator-style WORD append indicator with style WORD to entry names: none (default), slash (-p), file-type (--file-type), classify (-F)
-i, --inode print the index number of each file
-k, --kibibytes default to 1024-byte blocks for file system usage; used only with -s and per directory totals
--level DEPTH with -R or --tree, go at most DEPTH levels deep
-N, --literal print entry names without quoting
-l, --long use a long listing format
-o, --long-no-group like -l, but do not list group information
-g, --long-no-owner like -l, but do not list owner
-G, --no-group in a long listing, don't print group names
-n, --numeric-uid-gid like -l, but list numeric user and group IDs
--octal-permissions with -l, print the permission bits in octal too
-1, --one-per-line list one file per line
--only-dirs list only directories
--only-files list only files, not directories
--pretty WHEN[="always"] the gnux terminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal), or 'never'; colors every column, adds --header, -h and --group-directories-first; GNUX_PRETTY sets the default
-Q, --quote-name enclose entry names in double quotes
--quoting-style WORD use quoting style WORD for entry names: literal, locale, shell, shell-always, shell-escape, shell-escape-always, c, escape (overrides QUOTING_STYLE environment variable)
-R, --recursive list subdirectories recursively
-r, --reverse reverse order while sorting
--show-control-chars show nongraphic characters as-is (the default, unless program is 'ls' and output is a terminal)
--si likewise, but use powers of 1000 not 1024
-s, --size print the allocated size of each file, in blocks
-p, --slash append / indicator to directories
--sort WORD sort by WORD instead of name: none (-U), size (-S), time (-t), version (-v), extension (-X), name, width
-X, --sort-extension sort alphabetically by entry extension
-S, --sort-size sort by file size, largest first
-t, --sort-time sort by time, newest first; see --time
-v, --sort-version natural sort of (version) numbers within text
-T, --tabsize COLS assume tab stops at each COLS instead of 8
--theme NAME color the view with the built-in theme NAME (gnux themes shows them all); GNUX_THEME sets the default
--time WORD select which timestamp is shown or sorted on, WORD: access time (-u): atime, access, use; metadata change time (-c): ctime, status; modified time (default): mtime, modification; birth time: birth, creation
--time-style TIME_STYLE time/date format with -l, TIME_STYLE: full-iso, long-iso, iso, locale, or +FORMAT
--total-size show a directory's size as the total of everything in it
--tree list subdirectories recursively, drawn as a tree
-U, --unsorted do not sort; list entries in directory order
--version output version information and exit
-w, --width COLS set output width to COLS; 0 means no limit
--zero end each output line with NUL, not newlineExamples
List the current directory in columns
dirxKeep the columns when writing to a file
dirx > listing.txtInclude hidden entries
dirx -aList entries across rather than down
dirx -x srcFit the columns in 40 characters
dirx -w 40 /etcMark directories and executables
dirx -FSort by modification time, newest first
dirx -tShow sizes in blocks next to each name
dirx -shSwitch to the long format, as vdirx does
dirx -lList a directory in the portable gnux shell
gnux shell -c 'dirx -A dist'Options
Each option has a page of its own, with its usage and examples.
- -x, --across: List entries by lines instead of by columns.
- -a, --all: Do not ignore entries starting with .
- -A, --almost-all: Do not list implied . and ..
- -u, --atime: With
-lt: sort by, and show, access time; with-l: show access time and sort by name; otherwise: sort by access time, newest first. - --author: With
-l, print the author of each file. - --block-size: With
-l, scale sizes by SIZE when printing them; e.g., '--block-size=M'. - -F, --classify: Append indicator (one of */=@|) to entries.
- --color: Color the output WHEN: 'always' (the default when WHEN is omitted), 'auto', or 'never'.
- --color-scale: Color WHICH columns on a gradient by value: 'all' (the default when WHICH is omitted), 'size', 'age' or 'none'.
- -C, --columns: List entries by columns.
- -m, --commas: Fill width with a comma separated list of entries.
- -c, --ctime: With
-lt: sort by, and show, ctime (time of last change of file status information); with-l: show ctime and sort by name; otherwise: sort by ctime, newest first. - -L, --dereference: When showing file information for a symbolic
link, show information for the file thelinkreferences rather than for thelinkitself. - -H, --dereference-command-line: Follow symbolic links listed on the command line.
- -d, --directory: List directories themselves, not their contents.
- -D, --dired: Generate output designed for Emacs' dired mode.
- -b, --escape: Print C-style escapes for nongraphic characters.
- --file-type: Likewise, except do not append '*'.
- --format: Across
-x, commas-m, horizontal-x, long-l, single-column -1, verbose-l, vertical-C(WORD). - --full-time: Like
-l --time-style=full-iso. - --git: With
-l, print each file's git status (staged, then unstaged). - --git-ignore: Do not list entries that .gitignore rules exclude.
- --group-directories-first: Group directories before files; any use of
--sort=none (-U) disables grouping. - --header: With
-l, print a row naming each column. - --hide: Do not list implied entries matching shell PATTERN (overridden by
-aor-A). - -q, --hide-control-chars: Print ? instead of nongraphic characters.
- -h, --human-readable: With
-land-s, print sizes like 1K 234M 2G etc. - --hyperlink: Hyperlink file names WHEN: 'always' (the default when WHEN is omitted), 'auto', or 'never'.
- --icons: Show an icon (Nerd Font) before each name WHEN: 'always' (the default when WHEN is omitted), 'auto', or 'never'; GNUX_ICONS sets the default.
- -I, --ignore: Do not list implied entries matching shell PATTERN.
- -B, --ignore-backups: Do not list implied entries ending with ~.
- --indicator-style: Append indicator with style WORD to entry names: none (default), slash (
-p), file-type (--file-type), classify (-F). - -i, --inode: Print the index number of each file.
- -k, --kibibytes: Default to 1024-byte blocks for file system usage; used only with
-sand per directory totals. - --level: With
-Ror--tree, go at most DEPTH levels deep. - -N, --literal: Print entry names without quoting.
- -l, --long: Use a long listing format.
- -o, --long-no-group: Like
-l, but do not list group information. - -g, --long-no-owner: Like
-l, but do not list owner. - -G, --no-group: In a long listing, don't print group names.
- -n, --numeric-uid-gid: Like
-l, but list numeric user and group IDs. - --octal-permissions: With
-l, print the permission bits in octal too. - -1, --one-per-line: List one file per line.
- --only-dirs: List only directories.
- --only-files: List only files, not directories.
- --pretty: The
gnuxterminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal), or 'never'; colors every column, adds--header,-hand--group-directories-first; GNUX_PRETTY sets the default. - -Q, --quote-name: Enclose entry names in double quotes.
- --quoting-style: Use quoting style WORD for entry names: literal, locale, shell, shell-always, shell-escape, shell-escape-always, c, escape (overrides QUOTING_STYLE environment variable).
- -R, --recursive: List subdirectories recursively.
- -r, --reverse: Reverse order while sorting.
- --show-control-chars: Show nongraphic characters as-is (the default, unless program is '
ls' and output is a terminal). - --si: Likewise, but use powers of 1000 not 1024.
- -s, --size: Print the allocated size of each file, in blocks.
- -p, --slash: Append / indicator to directories.
- --sort: Sort by WORD instead of name: none (
-U), size (-S), time (-t), version (-v), extension (-X), name, width. - -X, --sort-extension: Sort alphabetically by entry extension.
- -S, --sort-size: Sort by file size, largest first.
- -t, --sort-time: Sort by time, newest first; see
--time. - -v, --sort-version: Natural sort of (version) numbers within text.
- -T, --tabsize: Assume tab stops at each COLS instead of 8.
- --theme: Color the view with the built-in theme NAME (
gnuxthemes shows them all); GNUX_THEME sets the default. - --time: Select which timestamp is shown or sorted on, WORD: access time (
-u): atime, access, use; metadata change time (-c): ctime, status; modified time (default): mtime, modification; birth time: birth, creation. - --time-style: Time/
dateformat with-l, TIME_STYLE: full-iso, long-iso, iso, locale, or +FORMAT. - --total-size: Show a directory's size as the total of everything in it.
- --tree: List subdirectories recursively, drawn as a tree.
- -U, --unsorted: Do not sort; list entries in directory order.
- -w, --width: Set output width to COLS; 0 means no limit.
- --zero: End each output line with NUL, not newline.
Exit status
| Status | Meaning |
|---|---|
| 0 | success |
| 1 | minor trouble: an entry found while listing could not be examined |
| 2 | serious trouble: a command-line operand could not be accessed, a directory could not be read, or a command-line mistake |
Help in the terminal
dirx --help # options, first examples, exit status
gnux help dirx # this page: the full manual
gnux help dirx --OPTION # one option in depth, with its examples