This ought to be really simple, but for some reason it is not working:
sed -i.bak -E 's/\t/ /' file.txt
Instead of replacing tab characters, it's replacing
t characters. I've tried every variation on this I could think of, playing with quoting, etc. I've Googled and found everyone else using pretty similar expressions and they seem to work for them.
-E is an OS X thing. I thought the failure might be a result of some weird quirk of OS X's
sed, so I tried it with Ruby as well (without the
-i), and got the same result:
ruby -pe '$_.gsub!(/\t/," ")' < file.txt > file.new
I'm using Bash 3.2.51 on OS X, and iTerm, although I can't see how any of those could be terribly relevant. I haven't set any weird environment variables, though I can post any that you think might be relevant.
What could be wrong?
UPDATE: I must have made some other mistake or typo when I tried the Ruby version, since Gilles points out that it does work (and I've never had him steer me wrong!). I'm not sure what happened, but I'm pretty sure it must have been my mistake.