How to remove files inside the hadoop directory at once?

Vishal picture Vishal · Aug 5, 2016 · Viewed 56.8k times · Source

I want to remove all the files containes in hadoop directory, without removing the directory itself. I've tried using rm -r but it removed the whole directory.

Answer

VenkateswaraCh picture VenkateswaraCh · Aug 6, 2016

Please include a wildcard character * after the desired folder you want to delete, to avoid deleting the parent folder. Please look at the example below:

hdfs dfs -rm -r /home/user/folder/*