How can the 'tr' command be used to convert lowercase letters to uppercase letters?

QuestionsQuestions8 SkillsProSimple Text ProcessingSep, 11 2025
0179

You can use the tr command in Linux to convert lowercase letters to uppercase letters by specifying the character sets for translation. Here’s the basic syntax:

tr 'a-z' 'A-Z' < input_file.txt > output_file.txt

Example

  1. Create a sample text file:

    echo 'hello world' > sample.txt
  2. Use the tr command to convert lowercase to uppercase:

    tr 'a-z' 'A-Z' < sample.txt > uppercase_sample.txt
  3. To verify the content of the new file:

    cat uppercase_sample.txt

You should see:

HELLO WORLD

This command reads from sample.txt, converts all lowercase letters to uppercase, and saves the result in uppercase_sample.txt.

0 Comments

no data
Be the first to share your comment!