Hamilton LaboratoriesHamilton C shell 2012User guideExternal utilities


Oregon Coast

Previous | Next

        Translate Characters Filter

Usage:  tr [-cdsnh-] [ string1 [string2] ]

   tr is used to perform simple character substitutions as it
   copies data from stdin to stdout.  Individual characters in
   string1 are mapped to the corresponding characters of string2.
   If string2 is too short, it is padded by duplicating its last
   character.  In either string, the minus sign can be used to
   indicate a range of characters.

   Here's an example which  creates a list of all the words in
   file1, one per line, in file2, where a word is taken as a maximal
   string of alphabetics.  (The ^n character is expanded by the
   C shell into a newline character.)

       % tr -csn A-Za-z ^n <file1 >file2


   -h         Help.  (This screen.)
   -c         Complement the set of characters in string1.
   -d         Delete any occurrences of the characters in string1.
              (If present, string2 is ignored.)
   -s         Squeeze all strings of repeated output characters
              in string2 to single characters.
   -n         Normalize line endings.  Ensure that every line ends
              with \r\n.  Fixup any \r or \n by itself or any
              reversed \n\r character pair.  When squeezing,
              normalization also causes repeated \r\n sequences
              to be squeezed if either \r or \n is in string2.
   --         End of options.

Previous | Next