linux delete all directories except one code example Example: delete all folders except one linux find * -maxdepth 0 -name 'b' -prune -o -exec rm -rf '{}' ';'