title: Why sudo cat gives a Permission denied but sudo vim works fine?
body: <p>I am trying to automate the addition of a repository source in my arch's pacman.conf file but using the <code>echo</code> command in my shell script.  However, it fails like this:-</p>
  
  <pre><code>sudo echo "[archlinuxfr]" &gt;&gt; /etc/pacman.conf
  sudo echo "Server = http://repo.archlinux.fr/\$arch" &gt;&gt; /etc/pacman.conf
  sudo echo " " &gt;&gt; /etc/pacman.conf
  
  -bash: /etc/pacman.conf: Permission denied
  </code></pre>
  
  <p>If I make changes to /etc/pacman.conf manually using vim, by doing</p>
  
  <pre><code>sudo vim /etc/pacman.conf
  </code></pre>
  
  <p>and quiting vim with <code>:wq</code>, everything works fine and my pacman.conf has been manually updated without "Permission denied" complaints.</p>
  
  <p>Why is this so? And how do I get <code>sudo echo</code> to work? (btw, I tried using <code>sudo cat</code> too but that failed with Permission denied as well) </p>