In this HackerRank 'Tr' Command #1 problem solution 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 [].

HackerRank 'Tr' Command #1 problem solution


Problem solution.

#!/bin/bash
cat $1 | tr "(" "[" | tr ")" "]"


Second solution.

tr '(' '[' | tr ')' ']'


Third solution.

tr '()' '[]'