title: Remove OS X Apps via Shell Script
body: <p>I'm trying to create a script that will remove a list of applications in OS X. 
  My general thinking:</p>
  
  <ol>
  <li>Applications are just directories in OS X</li>
  <li>Those directories have a Contents sub-directory that contains an Info.plist that can be used to identify the app.</li>
  </ol>
  
  <p>So the core logic would be </p>
  
  <ol>
  <li>Walk the drive</li>
  <li>IF the current folder has a subfolder named Contents that contains a file called Info.plist that contains certain text, delete the current folder.</li>
  </ol>
  
  <p>I've been playing around with find -exec, but am open to other approaches.</p>
  
  <p>This is what I have for find -exec that isn't quite working</p>
  
  <pre><code>find /Applications -maxdepth 3 -type f -name Info.plist -exec sh -c "grep '&lt;string&gt;Example&lt;/string&gt;' | xargs dirname | xargs echo rm --" 2&gt;/dev/null
  </code></pre>
  
  <p>I realize </p>
  
  <blockquote>
    <p>defaults read $dir/Contents/Info CFBundleExecutable</p>
  </blockquote>
  
  <p>is probably better than grep to extract the package name, but don't think that is why the above isn't working (no output from the test "echo rm" at all, and inserting a tee command to output to a file didn't do anything either).</p>
  
  <p>The above line, if it worked, would go in a loop running for each app to be removed with a list of app names in a variable.</p>
  
  <p>I am totally open to other approaches, especially if there's a more efficient way to do this.</p>