Linux Command Directory
This directory of Linux commands is from Linux in a Nutshell, 5th Edition.
Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.
tr [options] [string1 [string2] ]
Translate characters. Copy standard input to standard output, substituting characters from string1 to string2, or deleting characters in string1.
Complement characters in string1 with respect to ASCII 001-377.
Delete characters in string1 from output.
Squeeze out repeated output characters in string2.
Truncate string1 to the length of string2 before translating.
Print help message and then exit.
Print the version number and then exit.
Include brackets ([ ] ) where shown.
Ctrl-L (form feed)
Ctrl-M (carriage return)
Ctrl-K (vertical tab)
Character with octal value nnn
All characters in the range char1 through char2. If char1 does not sort before char2, produce an error.
In string2, expand char to the length of string1.
Expand char to number occurrences. [x*4] expands to xxxx, for instance.
Expand to all characters in class, where class can be:
Letters and digits
Printable characters except space
Whitespace (horizontal or vertical)
The class of characters to which char belongs.
Change uppercase to lowercase in a file:
cat file | tr 'A-Z' 'a-z'
Turn spaces into newlines (ASCII code 012):
tr ' ' ' ' < file
Strip blank lines from file and save in new.file (or use 011 to change successive tabs into one tab):
cat file | tr -s "" " " > new.file
Delete colons from file and save result in new.file:
tr -d : < file > new.file