UPPERCASE 2 lowercase conversion made easy

Got a legacy file in UPPERCASE – horrible, a crime against coding. But a lot of old code is like this (BASIC anyone??). In Unix it’s super easy to convert using the command tr. tr translates characters, and in the case below maps UPPERCASE characters to lowercase.

tr '[:upper:]' '[:lower:]' < inputFile > outputFile
Advertisements

One thought on “UPPERCASE 2 lowercase conversion made easy

  1. codeinfig says:

    that will translate all mixed-case strings to lowercase. admittedly, if you have input source with exactly zero mixed-case lines (such as from an apple ii) then you might as well go all lower. but if you have auto-capped keywords (such as from gw-basic) then you could use awk to only lower lines that dont have double quotes:

    awk ‘{ if (/”/) print $_ ; else print tolower($_)}’ inputFile > outputFile

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s