delete files and folders
Remove files and folders, ask before each, or remove huge folders quickly.
danger Steps marked in red delete, overwrite or stop something. Read each one before you run it.
Steps
-
rm file.txtdanger delete a file
-
rm -ri folderdanger delete a folder, asking for each file
-
rm -rf folderdanger delete a folder and everything in it, without asking
-
find . -name '*.tmp' -deletedanger delete every .tmp file under here
-
gio trash file.txtmove it to the desktop's trash instead
Notes
- There is no undo: check the path, mind spaces in names, and never run
rm -rfwith a variable that could be empty. - "Argument list too long": see the recipe on that, or use find -delete.
Commands used
rmfindgio
Each has a page in lore: lore rm opens it.
Related recipes
- add to the end of a fileAdd lines to a file without replacing it, also to a file only root can write.
- argument list too long"Argument list too long" from rm, cp or mv: too many files for one command line. Hand them over in batches.
- change permissions of a folder and everything in itGive a folder, its subfolders and its files the permissions or the owner they need, without making them open to everyone.
- check a file's permissionsSee who may read, write and run a file or a folder, and why a path is refused.