tr invocation (GNU Coreutils 9.0)
Next: expand invocation, Up: Operating on characters [Contents][Index]
9.1 tr: Translate, squeeze, and/or delete characters
Synopsis:
tr [option]… set1 [set2]
tr
copies standard input to standard output, performing one of the following operations:
- translate, and optionally squeeze repeated characters in the result,
- squeeze repeated characters,
- delete characters,
- delete characters, then squeeze repeated characters from the result.
The set1
and (if given) set2
arguments define ordered sets of characters, referred to below as set1
and set2
. These sets are the characters of the input that tr
operates on.
The program accepts the following options. Also see Common options. Options must precede operands.
- ‘
-c
’
‘-C
’
‘--complement
’ This option replaces
set1
with its complement (all of the characters that are not inset1
). Currentlytr
fully supports only single-byte characters. Eventually it will support multibyte characters; when it does, the-C
option will cause it to complement the set of characters, whereas-c
will cause it to complement the set of values. This distinction will matter only when some values are not characters, and this is possible only in locales using multibyte encodings when the input contains encoding errors.- ‘
-d
’
‘--delete
’ Delete characters in
set1
, do not translate- ‘
-s
’
‘--squeeze-repeats
’ Replace each sequence of a repeated character that is listed in the last specified
set
, with a single occurrence of that character.- ‘
-t
’
‘--truncate-set1
’ First truncate
set1
to length ofset2
.
An exit status of zero indicates success, and a nonzero value indicates failure.
• Character sets | Specifying sets of characters. | |
• Translating | Changing one set of characters to another. | |
• Squeezing and deleting | Removing characters. |
Next: expand invocation, Up: Operating on characters [Contents][Index]