title: In Mac OSX Lion, how does one replace multiple spaces with a single space using sed?
body: <p>friends, colleagues, glib claimers-to-know, and esteemed fellow victims of The Most Humiliating of Careers,</p>
  
  <p>I am suffering from that distinctive fatigue one gets when trying to do simple UNIXy things in Max OSX.  Can someone tell me how to use sed (not awk, not perl, not anything but sed) to take file.txt containing this:</p>
  
  <pre><code>Oh         my I         have Mac                 fatigue
  </code></pre>
  
  <p>and make it look like this:</p>
  
  <pre><code>Oh my I have Mac fatigue
  </code></pre>
  
  <p>Thank you very much if you actually do this on in Mac OSX Lion. (edit: not Mountain Lion, either, a different OS). I just spent a long time Googling folks who answer for linux or UNIX in general, it's not much help sadly.</p>
  
  <p>I tried a number of things from the blissful, long-forgotten days of standard pattern matching, when one could rattle off UNIXy commands and lo! they would behave:</p>
  
  <pre><code>cat file.txt | sed 's/ */ /g'        - O h m y I h a v e M a c f a t i g u e
  cat file.txt | sed 's/ \+/ /g'       - no effect
  cat file.txt | sed 's/\s\+/ /g'      - no effect
  cat file.txt | sed -E -e 's/ */ /g'  - O h m y I h a v e M a c f a t i g u e
  </code></pre>
  
  <p>Telling me to use sed on a linux machine will make me smile, but it won't get an upvote :)
  Thanks in advance.  Not sure what I'd do without StackOverflow.</p>