Linux

  1. Home
  2. Computing & Technology
  3. Linux

Dired Deletion

Emacs Documentation

By Juergen Haas, About.com

Deleting Files with Dired

One of the most frequent uses of Dired is to first flag files for deletion, then delete the files that were flagged.

  • d
    Flag this file for deletion.
  • u
    Remove deletion flag on this line.
  • <DEL>
    Move point to previous line and remove the deletion flag on that line.
  • x
    Delete the files that are flagged for deletion.

You can flag a file for deletion by moving to the line describing the file and typing d (dired-flag-file-deletion). The deletion flag is visible as a D at the beginning of the line. This command moves point to the next line, so that repeated d commands flag successive files. A numeric argument serves as a repeat count.

The variable dired-recursive-deletes controls whether the delete command will delete non-empty directories (including their contents). The default is to delete only empty directories.

The files are flagged for deletion rather than deleted immediately to reduce the danger of deleting a file accidentally. Until you direct Dired to delete the flagged files, you can remove deletion flags using the commands u and <DEL>. u (dired-unmark) works just like d, but removes flags rather than making flags. <DEL> (dired-unmark-backward) moves upward, removing flags; it is like u with argument -1.

To delete the flagged files, type x (dired-do-flagged-delete). (This is also known as expunging.) This command first displays a list of all the file names flagged for deletion, and requests confirmation with yes. If you confirm, Dired deletes the flagged files, then deletes their lines from the text of the Dired buffer. The shortened Dired buffer remains selected.

If you answer no or quit with C-g when asked to confirm, you return immediately to Dired, with the deletion flags still present in the buffer, and no files actually deleted.

* Emacs Manual Index

Explore Linux

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Linux

  1. Home
  2. Computing & Technology
  3. Linux
  4. Linux Software
  5. Editors
  6. Emacs
  7. Emacs Documentation - Dired Deletion

©2009 About.com, a part of The New York Times Company.

All rights reserved.