remove derived data with shell script

macos, removeall, rm, shell

Solution

- You cannot place `~` inside the quotes. Shell doesn't expand that.

- Variable assignment doesn't have `$` before the variable name.

Try this:

DIR=~/Library/Developer/Xcode/DerivedData/
cd $DIR
ls
rm -r -- "$DIR"*

Problem

I'm trying to create a sh to remove the contents of Xcode's deriveddate folder. I wrote this, it goes to the desired folder, and list the content, but when I remove the # and try to delete it, than it says ``` "**line 1: =~/Library/Developer/Xcode/DerivedData/: No such file or directory Desktop Downloads Movies Pictures clitools.dmg Documents Library Music Public override r--r--r-- dajkaferenc/staff for Desktop/Christmas Game update/.git/objects/00/8b8026f772525ccff6c3361ecc6f3eb43d0d82?** " $DIR="~/Library/Developer/Xcode/DerivedData/" cd $DIR ls #rm -r -- "$DIR"* ```

Original source