GREP в отдельной статье
tr, CUT
Подмена всех пробелов (в том числе повторяющихся) на одну запятую с использованием опции -s.
-s Squeeze multiple occurrences of the characters listed in the last operand (either string1 or string2) in the input into a single instance of the character.
Читать дальше