Convert text into the uppercase in Linux Using Shell Program

In Linux, Converting text to uppercase can be useful in many scenarios, such as when dealing with file names, or when preparing text for printing. In this article, we will explore how to convert text to uppercase using shell programs in Linux. Please copy this shell program so that you can use it when you need. Let’s go through below code:

 

 

 

Now Let us try to understand each line of the code briefly.

This is called a shebang, and it specifies the shell that should be used to interpret the script. In this case, it specifies the sh shell.

This is a comment that explains what the script does.

This line prompts the user to enter a filename.

This line reads the filename entered by the user and assigns it to the variable filename.

These two lines output a header to indicate the contents of the file before converting to uppercase.

This line uses the cat command to display the contents of the file.

These three lines output a header to indicate the contents of the file after converting to uppercase.

These two lines use the tr command to convert the contents of the file to uppercase. The first line is commented out and not used, while the second line actually performs the conversion. The tr command takes two arguments: the first argument specifies the characters to be replaced, and the second argument specifies the characters to replace them with. In this case, it replaces lowercase letters with uppercase letters.

In conclusion, converting text to uppercase in Linux can be done easily using shell programs such as tr. This method will be powerful tools that allow for efficient manipulation of text files in the Linux environment. you can gain a better understanding of how to use this command effectively and efficiently in your own Linux shell scripts. Please check out our another tutorial over linux. COMPARING CONTENTS TWO FILES AND SHOW OUTPUT USING SHELL PROGRAM

Scroll to Top