0
0
Linux CLIscripting~15 mins

tr (translate characters) in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Translate Characters Using tr Command
📖 Scenario: You work in a small office where you often receive text files with inconsistent letter cases. Your task is to create a simple script that converts all lowercase letters to uppercase letters to make the text uniform.
🎯 Goal: Build a script that uses the tr command to translate all lowercase letters in a given string to uppercase letters.
📋 What You'll Learn
Use the tr command to translate characters
Translate all lowercase letters to uppercase
Use echo to provide input text
Display the translated output
💡 Why This Matters
🌍 Real World
Translating text case is common when cleaning data or preparing text files for consistent formatting.
💼 Career
Many automation and scripting tasks require text manipulation using commands like <code>tr</code> to standardize input data.
Progress0 / 4 steps
1
Create a variable with lowercase text
Create a variable called text and assign it the value "hello world".
Linux CLI
Need a hint?

Use text="hello world" to create the variable.

2
Create a variable with uppercase letters
Create a variable called uppercase_letters and assign it the value "A-Z".
Linux CLI
Need a hint?

Use uppercase_letters="A-Z" to create the variable.

3
Translate lowercase letters to uppercase using tr
Use the echo command with the variable text and pipe it to tr to translate all lowercase letters a-z to uppercase letters using the variable uppercase_letters. Store the result in a variable called result.
Linux CLI
Need a hint?

Use result=$(echo "$text" | tr 'a-z' "$uppercase_letters") to translate and store the output.

4
Display the translated text
Print the variable result to display the translated uppercase text.
Linux CLI
Need a hint?

Use echo "$result" to print the translated text.