Run the given command:
$ man uniq
We get the following result:
uniq: report or omit multiple lines
Python has a way to implement this functionality. Of course one can do the following:
cmd = < # uniq command usage >
status, output = commands.getstatusoutput(cmd)
Using commands allows us to run any bash command from within Python.
The itertools module provides us with group by, which can be used to give results similar to uniq.
It can group “adjacent duplicate elements” together.
For the following code, an input of HHiiiii! will yield an output of
[(2,’H’), (5,’i’), (1,’!’)]