HackerRank - 'Tr' Command #1

April - 25/2025

Problem:

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

# Output

# Solution

            
    tr "(" "[" | tr ")" "]"
    

# Solution_01

            
    tr '()' '[]'
    

# Solution_02

            
    while read line
    do
        echo $line | tr "()" "[]";
    done
    echo $line | tr "()" "[]";
    

Post: