ubuntu remove all folders in a directory code example
Example 1: ubuntu remove all folders but keep some
find ./myfolder -mindepth 1 ! -regex '^./myfolder/test2\(/.*\)?' -delete
Example 2: ubuntu delete directory and all files
rm -rf ./test
find ./myfolder -mindepth 1 ! -regex '^./myfolder/test2\(/.*\)?' -delete
rm -rf ./test