how to delete folder and files in linux code example

Example 1: how to remove folder and its contents in linux

rm -rf dirname

Example 2: force delete a folder in linux

# To remove non-empty directories and all the files without being prompted, use rm with the -r (recursive) and -f options:
rm -rf dirname

Example 3: how to delete a dir in linux

#In linux Terminal:
	#To make a directory:
		mkdir directory_name
	#To delete a directory: 
		rmdir directory_name

Example 4: linux delete files in folders without deleting the folder

find /path/to/directory -type f -exec rm -iv {} \;

Tags:

Misc Example