tr

From NetBSD Wiki

Jump to: navigation, search
This article is a stub. You can help by editing it.

The tr(1) command translates a list of characters to another list of characters in a file.

Example:

$ echo abcdefabcdef | tr adf xyz
xbcyezxbcyez

Characters are positionally translated from the first list to the second. In the example, the character a is translated to an x, d is translated to y and f to z.

Other uses

You can also use tr to delete characters from its input, with the -d switch and only one list of characters:

$ echo abcdefabcdef | tr -d adf
bcebce

One common usage is to delete carriaage-return (ASCII 13) from files created in DOS or Windows systems:

$ tr -d '\r' <dos-file.txt >unix-file.txt

See also

View source code (Please report any bugs or suggestions here).

Retrieved from "http://wiki.netbsd.se/tr"
Personal tools