Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Next: , Previous: Dired Navigation, Up: Dired


38.3 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.


 
 
  Published under the terms of the GNU General Public License Design by Interspire