Friday, September 19, 2008

Change the case of file contents

If you want to change case (either lower or upper case) of contents of a file use the tr command.

Change contents of filename to lower case
cat filename | tr "[:upper:]" "[:lower:]" > newfilename
or
cat filename | tr '[A-Z]' '[a-z]' > newfilename

Change contents of filename to upper case
cat filename | tr "[:lower:]" "[:upper:]" > newfilename
or
cat filename | tr '[a-z]' '[A-Z]' > newfilename

No comments: