Last active
October 1, 2019 12:13
-
-
Save alexsorokoletov/3aa685c0d731d8f8eea44fc6cf0f6872 to your computer and use it in GitHub Desktop.
Clear bin/obj folders for Xamarin projects, as well as other temporary Xamarin files. Developer lifesaver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# based on http://stackoverflow.com/questions/755382/i-want-to-delete-all-bin-and-obj-folders-to-force-all-projects-to-rebuild-everyt | |
find . -iname "bin" -type d | xargs rm -rf | |
find . -iname "obj" -type d | xargs rm -rf | |
# clear VS4Mac temporary downloads | |
echo ~/Library/Caches/VisualStudio/7.0/TempDownload/ | |
for f in ~/Library/Caches/VisualStudio/7.0/TempDownload/* ; do | |
sudo rm -rf $f | |
done | |
#optionally you can run folowing to clear NuGet cache: nuget locals all -clear |
@martijn00 thanks, I like the idea of putting in path instead of opening folder you want to clear in terminal every time.
You can use pushd
and popd
instead of cd
, btw.
@martijn00 I've updated the snippet to include your suggestion.
Now checking only folders.
Nice. But it won't work on folders with spaces in the name. Consider the following replacement:
find . -iname "bin" -type d -o -iname "obj" -type d | tr '\n' '\0' | xargs -0 rm -rf
This combines two separate find commands into one (using the "or" operator on find)
It also prevents xargs from failing (xargs treats path names with spaces as separate arguments)
This alternative is terser, and works fine on the Mac.
Very nice, @scriptam!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't work if you have a lot of files in a directory. I've adjusted it to this to work: