unix remove directory and contents code example

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

rm -rf dirname

Example 2: how to remove directory in cmd

# for removing empty directory
$ rmdir myDirectory

# to remove a directory that contains files and subdirectory
$ rm -r myDirectory
rm -rf /config/filegroups/*/

Example 3: remove full dir

rm -r mydir

Example 4: remove directory from linux

rm -r filename

rm -rf filename

this command remove the directory and subdirectory forecefully

Example 5: how to delete directory in unix

rmdir directoryname  	// This is will delete an empty directory. 

rmdir -r directoryname 	// This is will delete everything in the directory
						// including all files and subdirectories.

Example 6: rm directory linux

To remove an empty directory, use either rmdir or rm -d followed by the directory name: 
rm -d dirname rmdir dirname.
To remove non-empty directories and all the files within them, use the rm command with the -r (recursive) option: 
rm -r dirname.