Unix Command to Delete all files in a directory but preserve the directory
rm -i <directory>/*
this should do the trick
EDIT: added -i just in case (safety first). directory should be a full or relative path (e.g. /tmp/foo
or ../trash/stuffs
)
you can remove all the files form the current directory using rm *
if you want to remove from a specific directory, type rm /path/*
try
rm -r yourDirectory/*
it deletes all file inside the "yourdirectory" directory
You can use find /path/to/your/folder/ -delete
to delete everything within that folder.
While a wildcard rm
would braek with too many files ("Argument list too long"), this works no matter how many files there are.
You can also make it delete only files but preserve any subdirectories:
find /path/to/your/folder/ -type f -delete
You could also specify any other criteria find
supports to restrict the "results".