find and delete bin/ and obj/ dirs adjacent to csproj files
find . -iname '*.csproj' -type f -print0 | xargs -0 -I{} sh -c 'rm -r $(dirname {})/{bin,obj}'
- find files with the csproj suffix
- output using null termination to help safely handle file names
- xargs option -0 signals the input lines are null terminated
- xargs option -p could prompt before executing
- xargs option -I designates the placeholder string
- run in a new shell process, because i want to use shell expansion techniques AFTER interpolation occurs
- dirname gets the absolute path that contains the csproj
- then shell expansion creates a command like
rm -r /path/bin /path/obj
clean bin obj
old version:
find . -iname 'bin' -type d -o -iname 'obj' -type d -print0 | xargs -0 -I{} rm -r {}
This isn't reliable. for starters, I think if one of bin/ or obj/ was missing, the other wouldn't get picked for deletion. Also, the find command's syntax is incredibly difficult to understand. The operator binding and general order of operations is opaque. There's syntax for grouping, but it adds a lot of visual noise and itself has behaviour that is difficult to predict.