How to use rimraf from cli to delete build folder but not remove the "build" folder itself

Viewed 834

I want to delete the build folder for my repo. All contents inside it. But I need to keep the build folder. Essentially clean everything inside the folder but remove it.

Currently I am using "rimraf build" in package.json scripts. But it removes the build folder as well.

How do i use rimraf ( or any other utility ) to remove the contents of a folder but not the folder itself?

1 Answers

rimraf <dirname>/* should delete all files but not the parent folder.

So, rimraf build/* should work for your case/

Related