Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.