Home > Bookmarks, Linux, Tech > Linux – Delete all files and folders in a folder recursively

Linux – Delete all files and folders in a folder recursively

Linux command that will delete all files & folders in a certain directory:

for current path

  1. cd to directory
  2. rm -Rf *

or for absolute path:

  1. rm -Rf /home/some/directory/*

another option (this will only delete files of type f which is a regular file):

  1. find /some/path/ -type f -exec rm -f ‘{}’ \;

If you are trying to delete too many files in a directory at the same time read here: /bin/rm Argument list too long – Linux

  1. No comments yet.
  1. No trackbacks yet.
GoCache - ByREV-Cache v1.0 - live served in : 0.15177 sec (gzip)