title: How to accept Xcode license in a automation way?
body: <p>In order to accept the <strong>Xcode License</strong> in CLI, we can run</p>
  
  <pre><code>sudo xcodebuild -license
  </code></pre>
  
  <p>Then the console will prompt</p>
  
  <blockquote>
    <p>You have not agreed to the Xcode license agreements. You must agree to
    both license agreements below in order to use Xcode.</p>
    
    <p>Hit the Enter key to view the license agreements at
    '/opt/homebrew-cask/Caskroom/xcode/7.1/Xcode.app/Contents/Resources/English.lproj/License.rtf'</p>
  </blockquote>
  
  <p>By pressing <kbd>Enter</kbd>, the screen will display the license and at the bottom of screen, it prompts</p>
  
  <blockquote>
    <p>Software License Agreements Press 'space' for more, or 'q' to quit</p>
  </blockquote>
  
  <p>By pressing <kbd>q</kbd>, we can quickly mark the license as read, then the final prompt shows up</p>
  
  <blockquote>
    <p>By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel]</p>
  </blockquote>
  
  <p>By pressing <kbd>agree</kbd>, the license was finally accepted.</p>
  
  <p><strong>But the whole process need human's interaction, is there a way to accept the license automatically?</strong></p>
  
  <p>I tried the following commands, none is work.</p>
  
  <pre><code>sudo echo -e "\nq\nagree\n" | sudo xcodebuild -license
  
  sudo echo -e "agree" | sudo xcodebuild -license
  </code></pre>