HackerRank - 'Tr' Command #3
April - 25/2025Problem:
In a given fragment of text, replace all sequences of multiple spaces with just one space.
# Input
- He llo
- Wor ld
- how are you
# Output
- He llo
- Wor ld
- how are you
# Solution
tr -s ' '
# Solution_01
tr -s [:space:]
# Solution_02
while read line
do
echo "$line" | tr -s ' '
done