Reverse case with a ruby one-liner

Alec Jacobson

September 12, 2013

weblog/

I needed to reverse the case of every character. I used a ruby one-liner:

echo "FooBar" | ruby -ne 'puts $_.split("").map{|e| (e>="a"?e.upcase():e.downcase())}.join'

Returns

fOObAR