AWK: convert into lower or upper cases

In order to convert a bash variable to lower case with awk, just use this command:

a="UPPER CASE"
echo "$a" | awk '{print tolower($0)}'

If you want to convert the content of a file (called data.csv) to lower case:

awk '{print tolower($0)}' data.csv

Of course to convert into upper case, simply use the function toupper() instead of tolower().

Note also that a better tool to avoid issues with special characters might be the tr unix command:

tr [:upper:] [:lower:] < input
Please follow and like us:
This entry was posted in Linux and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *