YouTip LogoYouTip

Linux Comm Tr

[![Image 1: Linux Command Manual](#) Linux Command Manual](#) The Linux `tr` command is used to translate or delete characters in a file. The `tr` command reads data from the standard input device, performs string translation, and outputs the result to the standard output device. ### Syntax tr tr …SET1 **Parameter Description:** * -c, --complement: Complement the set of characters in SET1. This means characters matching SET1 are not processed, and the remaining characters are translated. * -d, --delete: Delete characters specified in SET1. * -s, --squeeze-repeats: Replace each sequence of a repeated character that is listed in the last operand with a single occurrence of that character. * -t, --truncate-set1: First truncate SET1 to length of SET2. * --help: Display help information. * --version: Display version information. Character Set Ranges: * NNN: Character with the octal value NNN (1 to 3 octal digits). * : Backslash. * a: Ctrl-G (Alert/Bell). * b: Ctrl-H (Backspace). * f: Ctrl-L (Form feed). * n: Ctrl-J (Newline). * r: Ctrl-M (Carriage return). * t: Ctrl-I (Horizontal tab). * v: Ctrl-X (Vertical tab). * CHAR1-CHAR2: Character range from CHAR1 to CHAR2, specified in ASCII order. The range must be ascending (e.g., a-z). * [CHAR*]: Used only in SET2. Repeat the specified character until the output matches the length of SET1. * [CHAR*REPEAT]: Used only in SET2. Repeat the specified character REPEAT times (REPEAT is an octal number, starting with 0). * [:alnum:]: All letters and digits. * [:alpha:]: All letters. * [:blank:]: All horizontal whitespace. * [:cntrl:]: All control characters. * [:digit:]: All digits. * [:graph:]: All printable characters, excluding whitespace. * [:lower:]: All lowercase letters. * [:print:]: All printable characters, including whitespace. * [:punct:]: All punctuation characters. * [:space:]: All horizontal and vertical whitespace. * [:upper:]: All uppercase letters. * [:xdigit:]: All hexadecimal digits. * : All characters equivalent to CHAR (CHAR is a custom character). ### Examples To convert all lowercase letters in the file `testfile` to uppercase, you can use the following command: cat testfile | tr a-z A-Z The content of the `testfile` is as follows: $ cat testfile # Original content of testfile Linux networks are becoming more and more common, but scurity is often an overlooked issue. Unfortunately, in today’s environment all networks are potential hacker targets, fro0m tp-secret military research networks to small home LANs. Linux Network Securty focuses on securing Linux in a networked environment, where the security of the entire network needs to be considered rather than just isolated machines. It uses a mix of theory and practicl techniques to teach administrators how to install and use security applications, as well as how the applcations work and why they are necesary. After using the `tr` command for case conversion, the output is as follows: $ cat testfile | tr a-z A-Z # Converted output LINUX NETWORKS ARE BECOMING MORE AND MORE COMMON, BUT SECURITY IS OFTEN AN OVERLOOKED ISSUE. UNFORTUNATELY, IN TODAY’S ENVIRONMENT ALL NETWORKS ARE POTENTIAL HACKER TARGETS, FROM TP-SECRET MILITARY RESEARCH NETWORKS TO SMALL HOME LANS. LINUX NETWORK SECURTY FOCUSES ON SECURING LINUX IN A NETWORKED ENVIRONMENT, WHERE THE SECURITY OF THE ENTIRE NETWORK NEEDS TO BE CONSIDERED RATHER THAN JUST ISOLATED MACHINES. IT USES A MIX OF THEORY AND PRACTICL TECHNIQUES TO TEACH ADMINISTRATORS HOW TO INSTALL AND USE SECURITY APPLICATIONS, AS WELL AS HOW THE APPLCATIONS WORK AND WHY THEY ARE NECESARY. Case conversion can also be achieved using the `[:lower:]` and `[:upper:]` character classes. For example, using the following command: cat testfile | tr [:lower:] [:upper:] The output is as follows: $ cat testfile | tr [:lower:] [:upper:] # Converted output LINUX NETWORKS ARE BECOMING MORE AND MORE COMMON, BUT SECURITY IS OFTEN AN OVERLOOKED ISSUE. UNFORTUNATELY, IN TODAY’S ENVIRONMENT ALL NETWORKS ARE POTENTIAL HACKER TARGETS, FROM TP-SECRET MILITARY RESEARCH NETWORKS TO SMALL HOME LANS. LINUX NETWORK SECURTY FOCUSES ON SECURING LINUX IN A NETWORKED ENVIRONMENT, WHERE THE SECURITY OF THE ENTIRE NETWORK NEEDS TO BE CONSIDERED RATHER THAN JUST ISOLATED MACHINES. IT USES A MIX OF THEORY AND PRACTICL TECHNIQUES TO TEACH ADMINISTRATORS HOW TO INSTALL AND USE SECURITY APPLICATIONS, AS WELL AS HOW THE APPLCATIONS WORK AND WHY THEY ARE NECESARY. [![Image 2: Linux Command Manual](#) Linux Command Manual](#)
← Linux Comm ExprLinux Comm Spell β†’