Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The sed FAQ
Prev Home Next

4.16. How do I convert a string to all lowercase or capital letters?

The easiest method is to use a new version of GNU sed, ssed, sedmod or sed16 and employ the \U, \L, or other switches on the right side of an s/// command. For example, to convert any word which begins with "reg" or "exp" into solid capital letters:

       sed -r "s/\<(reg|exp)[a-z]+/\U&/g"              # gsed4.+ or ssed
       sed "s/\<reg[a-z]+/\U&/g; s/\<exp[a-z]+/\U&/g"  # sed16 and sedmod

As you can see, sedmod and sed16 do not support alternation (|), but they do support case conversion. If none of these versions of sed are available to you, some sample scripts for this task are available from the Seder's Grab Bag:

       https://sed.sourceforge.net/grabbag/scripts

Note that some case conversion scripts are listed under "Filename manipulation" and others are under "Text formatting."

The sed FAQ
Prev Home Next

 
 
   Reprinted courtesy of Eric Pement. Also available at https://sed.sourceforge.net/sedfaq.html Design by Interspire