Author Topic: Delete all files and subfolders in a Linux directory  (Read 183 times)

spiros

  • Administrator
  • Hero Member
  • *****
  • Posts: 296449
  • Gender: Male
  • point d’amour
    • spiros.doikas
    • greektranslator
    • doikas
    • 102094522373850556729
    • lavagraph
    • Greek translator CV
Delete all files and subfolders in a Linux directory
« on: 25 Jun, 2017, 09:03:11 »
rm -rf /path/to/directory

Delete all files and subfolders in a Linux directory (including that directory)

rm is command to remove/delete stuff. -rf is two options joined together: -r for recursive removal (typically used with directories) and -f to force the action

rm -rf /path/to/directory/*

Remove all the contents of the folder (including all interior folders) but not the folder itself.

rm -f /path/to/directory/*

Remove all files (but no subfolders) in a directory

rm -rf /path/to/directory/{*,.*}

Remove all files in directory (including hidden files and subdirectories).
« Last Edit: 25 Jun, 2017, 12:19:07 by spiros »