tr command line

 1. How to convert lower case to upper case

To convert from lower case to upper case the predefined sets in tr can be used.

$cat greekfile

Output:

WELCOME TO 
GeeksforGeeks
$cat greekfile | tr “[a-z]” “[A-Z]”

Output:

WELCOME TO
GEEKSFORGEEKS

or

$cat geekfile | tr “[:lower:]” “[:upper:]”

Output:

WELCOME TO
GEEKSFORGEEKS

2. How to translate white-space to tabs
The following command will translate all the white-space to tabs

$ echo "Welcome To GeeksforGeeks" | tr [:space:] '\t'

Output:

Welcome    To    GeeksforGeeks    

3. How to translate braces into parenthesis
You can also translate from and to a file. In this example we will translate braces in a file with parenthesis.



$cat greekfile

Output:

 {WELCOME TO} 
GeeksforGeeks
$ tr '{}' '()'   newfile.txt

Output:

(WELCOME TO) 
GeeksforGeeks

Comments

Popular posts from this blog

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

Amazon Linux 2023 - User data configuration for launch templates to connect to the EKS cluster

How to create ISM policy and rotate logs in opensearch