title: How to decode URL-encoded string in shell?
body: <p>I have a file with a list of user-agents which are encoded.
  E.g.:</p>
  
  <pre><code>Mozilla%2F5.0%20%28Macintosh%3B%20U%3B%20Intel%20Mac%20OS%20X%2010.6%3B%20en
  </code></pre>
  
  <p>I want a shell script which can read this file and write to a new file with decoded strings.</p>
  
  <pre><code>Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en
  </code></pre>
  
  <p>I have been trying to use this example to get it going but it is not working so far.</p>
  
  <pre><code>$ echo -e "$(echo "%31+%32%0A%33+%34" | sed 'y/+/ /; s/%/\\x/g')"
  </code></pre>
  
  <p>My script looks like:</p>
  
  <pre><code>#!/bin/bash
  for f in *.log; do
    echo -e "$(cat $f | sed 'y/+/ /; s/%/\x/g')" &gt; y.log
  done
  </code></pre>