- Print the list of directories echo target/*/
- Flip space separator to newline tr " " "\n"
- Remove the line for the directory to keep grep -v keepme
- Flip newline back to space tr "\n" " "
- Run rm -rf on the results from steps 1-4
As a 1-liner:
rm -rf $(echo target/*/ | tr " " "\n" | grep -v keepme | tr "\n" " ")
Noting it in case I need to do it again someday ;)
1 comment:
How about this one:
find target/* ! -iname keepme -print0 | xargs -0 rm -rf
this works for me
Post a Comment