title: How to reverse each word in a text file with linux commands without changing order of words
body: <p>There's lots of questions indicating how to reverse each word in a sentence, and I could readily do this in Python or Javascript for example, but how can I do it with Linux commands? It looks like <code>tac</code> might be an option, but seems like this would likely reverse lines as well as words, rather than just words? What other tools can do this? I literally have no idea. I know <code>rev</code> and <code>tac</code> and <code>awk</code> all seem like contenders...</p>
  
  <p>So I'd like to go from:</p>
  
  <pre><code>cat dog sleep
  pillow green blue
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>tac god peels
  wollip neerg eulb
  </code></pre>
  
  <p>**slight followup</p>
  
  <p>From <a href="http://www.staff.science.uu.nl/~oostr102/docs/nawk/nawk_92.html" rel="nofollow">this reference</a> it looks like I could use <code>awk</code> to break each field up into an array of single characters and then write a for loop to reverse manually each word in this way. This is quite awkward. Surely there's a better/more succinct way to do this?</p>