(dired.info)Listing Files in Dired
Next: Marking Files in Dired Prev: Editing in Dired Up: Dired
Listing Files in Dired
Initially the Dired buffer shows the directory you selected. The first
line shows the full directory name. It is an example of a "headerline"
of a directory. Note that it is terminated by a colon (`:') that is
not part of the directory name. The second line usually displays the
total size of all files in the directory or the wildcard used. Both
are examples of "non-file lines". Applying a command to a non-file
line signals an error. The other lines of the directory, called the
"file lines", show information about each file such as permission bits,
size and date of last modification, and the name of the file.
For example, the listing
-rw-r--r-- 1 sk users 231608 Feb 6 16:58 ChangeLog
drwxr-sr-x 2 sk users 2048 Feb 6 11:07 RCS
-r--r--r-- 1 sk users 141389 Feb 6 10:45 dired.el
-r--r--r-- 1 sk users 113033 Feb 5 16:21 dired.texi
-r--r--r-- 1 sk users 231748 Feb 6 16:59 dired.texi,v
-r--r--r-- 1 sk users 763898 Feb 6 10:45 dired.el,v
has a headerline for the `lisp' directory, a total line saying there
are 4973 K in all the files of that directory (your `ls' program may
use units of blocks instead), and several file lines. After that, a
headerline for the `RCS' subdirectory with its total line and its files
Here is an example of a wildcard listing:
-rw-r--r-- 1 sk users 113036 Feb 6 16:59 dired.texi
-r--r--r-- 1 sk users 81267 Feb 6 16:29 dired.elc
-r--r--r-- 1 sk users 38436 Feb 6 16:28 dired-x.elc
-r--r--r-- 1 sk users 60258 Feb 6 16:27 dired-x.el
-r--r--r-- 1 sk users 141389 Feb 6 10:45 dired.el
Since `ls' does not provide a total count when called with a wildcard
argument, the second line now gives instead the wildcard used, here
`dired*'. If there would have been a directory matching the wildcard,
e.g. a `dired/' subdirectory, its file line would be shown, but it
would not have been expanded automatically.
Filenames may have embedded and trailing (but not leading) spaces.
Leading spaces are not recognized because different `ls' programs
differ in the amount of whitespace the insert before the filename.
Filenames may *not* contain newlines or `^M''s. You can get away with
`^M''s in filenames if you do
(setq selective-display nil)
in the Dired buffer (inside `dired-mode-hook', Note: Dired Hooks.).
But this also disables the `=' and `$' hiding commands, Note: Hiding
Directories in Dired.
Other unprintable characters than `^M' or newline (`^J') in
filenames are no problem for Dired. But your `ls' program may not
output them correctly (e.g., replacing all unprintable characters with a
question mark `?'). Dired can do nothing if `ls' suppresses
information about the filenames. But some (System V derived) `ls'
programs have a `-b' switch to quote control characters, e.g. `\n' for
a newline character, or `\007' for a ASCII bell character (`C-g'), so
you might want to add `b' to your switches (see below). Dired
translates the quoted control character escapes when a `-b' switch was
used. The `-b' switch is the recommended method to cope with funny
filenames containing newlines or leading spaces. But check if your
`ls' understands `-b' and really quotes newlines and spaces. Dired is
known to work with GNU `ls -b', but other `ls -b' don't quote spaces,
so leading spaces still don't work with these `ls' programs.
The appearance of the listing is determined by the listing switches
used, for example whether you display or suppress `.' files with the
`-a' and `-A' switches, use the `-F' switch to tag filenames etc. It
may additionally be restricted to certain files if you used wildcards
to display only those files matching a shell file wildcard.
Dired has commands that change the listing switches for this buffer.
They are mainly used to set the sort mode, but can also be used to
change other formatting options. The buffer is automatically refreshed
after the switches are changed to let the new format take effect.
The default value for the switches comes from the variable
`dired-listing-switches'; a prefix argument to `dired' can be use to
determine the switches used for a specific buffer. Note: Entering
Dired. Each Dired buffer has its own value for the switches, stored
in the variable `dired-actual-switches'.
The Dired modeline displays `by name' or `by date' to indicate the
sort mode. It uses the regexps in the variables
`dired-sort-by-date-regexp' and `dired-sort-by-name-regexp' to decide
what should be displayed. If neither of the regexps matches, the
listing switches are displayed literally. You can use this to always
display the literal switches instead of `by name' or `by date': set
them to a regexp that never matches any listing switches, for example
Most `ls' programs can only sort by name (without `-t') or by date
(with `-t'), nothing else. GNU `ls' additionally sorts on size with
`-S', on extension with `-X', and unsorted (in directory order) with
`-U'. So anything that does not contain these is sort "by name".
However, this is configurable in the variable
`dired-ls-sorting-switches', which defaults to `"SXU"'. It contains a
string of `ls' switches (single letters) except `t' that influence
sorting. It is consulted at load time, so if you redefine it, you must
do it before Dired is loaded.
(`dired-sort-toggle-or-edit') Toggle between sort by name/date and
refresh the dired buffer. With a prefix argument you can edit the
current listing switches instead.
After some time the listing may become out of date because of
actions by other programs than Dired. You can refresh the complete
Dired buffer from disk or only refresh the lines of certain files or a
(`dired-do-redisplay') Redisplay all marked (or, with a prefix
argument, the next N) files. As always, if no files are marked,
the current file is used.
If on a headerline, redisplay that subdirectory. In that case, a
prefix arg lets you edit the `ls' switches used for the new
(`revert-buffer') The `g' command in Dired ultimately runs
`dired-revert' to reinitialize the buffer from the actual disk
directory (or directories). All marks and flags in the Dired
buffer are restored, except of course for files that have
vanished. Hidden subdirectories are hidden again. Note: Hiding
Directories in Dired.
(`dired-kill-line-or-subdir') Kill this line (but not this file).
Optional prefix argument is a repeat factor. If file is displayed
as expanded subdirectory, kill that as well.
If on a subdirectory line, kill that subdirectory. Reinsert it
with `i' (`dired-maybe-insert-subdir'), Note: Subdirectories in
Killing a file line means that the line is removed from the Dired
buffer. The file is not touched, and the line will reappear when
the buffer is refreshed (using `g', `revert-buffer'). A killed
subdirectory will not reappear after reverting the buffer, since
`g' only list those subdirectories that were listed before.
(`dired-do-kill') Kill all marked lines (not files). With a prefix
argument, kill all lines not marked or flagged.
(For file marking, Note: Marking Files in Dired.)
(`dired-undo') Undo in a Dired buffer. This doesn't recover lost
files, it is just normal undo with a temporarily writable buffer.
You can use it to recover marks, killed lines or subdirs. In the
latter case, you have to do `M-x dired-build-subdir-alist' to
parse the buffer again for the new subdirectory list.
automatically generated by info2www