How do you delete all files within a directory on Linux?

You can use the following command to delete all files in a directory:

$ rm -r /path/to/directory/*

In the above command, ‘rm’ is the delete command, ‘-r’ is the recursive delete option, and ‘/path/to/directory/*’ is the wildcard path for all files inside the directory to be deleted.

Please note that this is a very powerful command, once executed the deleted files cannot be recovered, so please proceed with caution.

bannerAds