so I want to clean a directory before I start work. I looks a bit like this../static css  styles img  pictures js     scriptsI want to rm the contents of css and js but not img.I know I could just put both paths in but it bothers me so I tried this, with no success.rm -r ./static/{css,js}/*rm: cannot remove './static/{css,js}/*': No such file or directoryAny ideas how I could make this work?
find all files excluding one directory
bash;rm
Your command is treated * as a file, try rm -rf ./static/{css,js}/Alternatively,Bash has extended globbing (first test, then remove the echo):$ shopt -s extglob$ cd static$ echo rm -rf !(img)Or Short Answerls | grep -v img | xargs rm -rfAs suggested by OP in comment, Follow this step to do your job.First dry run by printing the files to make sure you get what you are looking for.$ find . -path ./img -prune -o -type f./css/styles./img./js/scriptsAfter confirming, delete it.$ find . -path ./img -prune -o -type f -exec rm {} \;$ static/   css   img    pictures   js