Wednesday, February 24, 2016

Convert all text in a file from UPPER to lowercase on LINUX

Convert all text in a file from UPPER to lowercase

To translate or delete characters use tr command. The basic syntax is:

Lets create a simple text file with mix of lower and upper case chars :
oracle@Linux01:[/u01/app/oracle/admin/bin] $ vi TGTGTG.txt

oracle@Linux01:[/u01/app/oracle/admin/bin] $ cat TGTGTG.txt
as This IS in Upper

Here I am passing the TGTGTG.txt as inprt and converting the output to lower case:
oracle@Linux01:[/u01/app/oracle/admin/bin] $ tr '[:upper:]' '[:lower:]' < TGTGTG.txt > output.txt

oracle@Linux01:[/u01/app/oracle/admin/bin] $ cat output.txt
as this is in upper

Here I am passing the TGTGTG.txt as inprt and converting the output to UPPER case:
oracle@Linux01:[/u01/app/oracle/admin/bin] $ tr '[:lower:]' '[:upper:]' < TGTGTG.txt > output_UP.txt

oracle@Linux01:[/u01/app/oracle/admin/bin] $ cat output_UP.txt
AS THIS IS IN UPPER

oracle@Linux01:[/u01/app/oracle/admin/bin] $

No comments:

Post a Comment