I want to remove all directories in a folder, no mater the specified directory is empty or not. Can I do this in command line?
Asked
Active
Viewed 65 times
If I understand you correctly, you want to remove all subdirectories in a folder without deleting the files.
Then the following bash script can help you.
#!/bin/bash
for i in `ls`
do
if [ -d $i ];then
rm -rf $i
fi
done