-2

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?

Koen
  • 311
  • 2
  • 11

1 Answers1

-1

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
taseikyo
  • 126
  • 7