‘Tr’ Command #1 – HackerRank Solution

In this post, we will solve ‘Tr’ Command #1 HackerRank Solution. This problem (‘Tr’ Command #1) is a part of Linux Shell series.


In this challenge, we practice using the tr command because it is a useful translation tool in Linux.

In a given fragment of text, replace all parentheses () with box brackets [].

Input Format

A block of ASCII text.

Output Format

Output the text with all parentheses () replaced with box brackets [].

Sample Input

int i=(int)5.8
(23 + 5)*2

Sample Output

int i=[int]5.8
[23 + 5]*2

Solution – ‘Tr’ Command #1 – HackerRank Solution

#Output the text with all parentheses () replaced with box brackets []. 
tr "()" "[]"

Note: This problem (‘Tr’ Command #1) is generated by HackerRank but the solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.

Leave a Comment

Your email address will not be published. Required fields are marked *