Created
February 18, 2014 19:47
-
-
Save magickatt/9078526 to your computer and use it in GitHub Desktop.
Delete only directories (not files) in a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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