Quick Ruby Upcase Filter

This is a real quick one. I noticed uuidgen under linux produces lower case strings, while it’s Mac OS X counterpart produces uppercase strings. I generate UUID’s for the certificate CN field in Puppet, so I wanted them to match.

This one-liner did the trick nicely.

uuidgen | ruby -pe '$_.upcase!'
Tags: , , ,  

No Comments

  1. Clay Caviness

    The old-time UNIX geek in me doesn’t like calling ruby when a much more lightweight solution has been around for ages: tr.

    $ uuidgen | tr a-z A-Z
    will do what you’re looking for with a bit fewer resources used (not that you’ll actually notice on a modern box).

    (It turns out you actually want ‘tr “[:lower:]” “[:upper:]“‘ to be a nice member of the global community and deal with locales properly, but that’s a lot of extra typing.)

Leave a comment

You must be logged in to post a comment.