Skip to content

Instantly share code, notes, and snippets.

@magickatt
Created February 18, 2014 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magickatt/9078526 to your computer and use it in GitHub Desktop.
Save magickatt/9078526 to your computer and use it in GitHub Desktop.
Delete only directories (not files) in a directory
#!/bin/bash
# Make a directory with some test directories and files inside
mkdir test
cd test
mkdir test1
mkdir test2
mkdir test3
touch hello.txt
touch goodbye.txt
touch samurai.txt
ls
# goodbye.txt hello.txt samurai.txt test1 test2 test3
# Delete the directories only
rm -r */
ls
# goodbye.txt hello.txt samurai.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment