home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 34.11 Search & Replacement: One Match Among Many Chapter 34
The sed Stream Editor
Next: 34.13 Hold Space: The Set-Aside Buffer
 

34.12 Transformations on Text

The transform command ( y ) is useful for exchanging lowercase letters for uppercase letters on a line. Effectively, it performs a similar function to tr ( 35.11 ) . It replaces any character found in the first string with the equivalent character in the second string. The command:

y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/

will convert any lowercase letter into the corresponding uppercase letter. The following:

y/abcdefghijklmnopqrstuvwxyz/nopqrstuvwxyzabcdefghijklm/

would perform a rot13 transformation - a simple form of encryption in which each alphabetic character is replaced by the character halfway through the alphabet. ( rot13 encryption is sometimes used to keep offensive news postings ( 1.33 ) from being read except by someone who really means to. Encryption and decryption are automatically supported by most news readers, but it's fun to see how simple the encryption is. By the way, the command above handles only lowercase letters; if we'd shown uppercase as well, the command would have run past the margins!)

- TOR


Previous: 34.11 Search & Replacement: One Match Among Many UNIX Power Tools Next: 34.13 Hold Space: The Set-Aside Buffer
34.11 Search & Replacement: One Match Among Many Book Index 34.13 Hold Space: The Set-Aside Buffer

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System