I have an exercise in which I have to get a string from the user read str
and to print the number of times which the last character of this string is being repeated.
For example, the string is: ab2aa2b122
and the output will be : 4
because 2
is being repeated 4 times in the string.
My problem is to divide the string into single characters. I want that every character will be separated from the other character by space " "
or by a \n
in order to use the tr
command and uniq
command.
I have to use uniq
and sort
commands, in order to use these I have to split the characters, which means that every character must be separated by space or by \n
.