Example list:
goodbye
goodbye
hello
hi
hi
hi
no
Expected output:
goodbye goodbye
hello
hi hi hi
no
I'd like to print the even the 'unlike' word as well, just on a separate individual line. But any matching on the same line. Can 'tr' be used with a loop?
#!/bin/bash
while read line
do
if [$var == $var]
then
echo $var | tr -s ' '
else
echo $var | tr '\n'
fi
done < foo.txt