tr-translates characters

 <  Day Day Up  >  

tr ” translates characters

 tr [ cds ] [ string1 [ string2 ] ] 

tr copies the standard input to the standard output with substitution or deletion of selected characters. Input characters found in string1 are mapped into the corresponding characters of string2 . The forward slash can be used with an octal digit to represent the ASCII code. When string2 (with any repetitions of characters) contains fewer characters than string1 , characters in string1 with no corresponding character in string2 are not translated. Octal values for characters may be used when preceded with a backslash:

\11

Tab

\12

Newline

\042

Single quote

\047

Double quote


Example A.63.
 1   tr 'A' 'B' < filex 2   tr '[A-Z]' [a-z]' < filex 3   tr -d ' ' < filex 4   tr -s '' '' < filex 5   tr -s ':' ' ' < filex 6   tr '7' '2' 

EXPLANATION

  1. Translates As to Bs in filex .

  2. Translates all uppercase letters to lowercase letters .

  3. Deletes all spaces from filex .

  4. Replaces (squeezes) multiple tabs with single tabs in filex .

  5. Squeezes multiple colons into single spaces in filex .

  6. Translates double quotes to single quotes in text coming from standard input.

 <  Day Day Up  >  


UNIX Shells by Example
UNIX Shells by Example (4th Edition)
ISBN: 013147572X
EAN: 2147483647
Year: 2004
Pages: 454
Authors: Ellie Quigley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net