linux delete directory recursively code example
Example 1: how to remove folder and its contents in linux
rm -rf dirname
Example 2: delete a directory bash script
rmdir dirname
Example 3: remove full dir
rm -r mydir
Example 4: 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 5: linux command to delete direcoty with specified name recursivel
# First find the directory names as to not accidentally delete important directories
find . -type d -name __pycache__
# If you want to recursively delete its contents, replace -exec rmdir {} \; by -delete or -prune -exec rm -rf {} \;. Other answers include details about these versions, credit them too.
find . -type d -name __pycache__ -prune -exec rm -rf {} \;