[sf-lug] convert to lowercase

Michael Paoli Michael.Paoli at cal.berkeley.edu
Mon Sep 17 16:42:08 PDT 2007


$ cat file
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
$ ex file << \__EOT__
> %s/[A-Z]/\l&/g
> w
> q
> __EOT__
$ cat file
abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz
$ 

One of the advantages of the method shown above, is that it
preserves the inode and (hard) link relationships (and ownerships
and permissions) of the file - no explicit intermediary file required.

Extra credit: name a disadvantage with the above (hint: multiuser, multitasking)

Quoting Alden Meneses <aldenm at gmail.com>:

> I was wondering if anyone knew how to convert a text file to all lowercase.




More information about the sf-lug mailing list