I don't think cat
command will do the job alone. I guess you should have a look at gnu core utils package where you will find a lot of tools: http://www.gnu.org/software/coreutils/manual/html_node/index.html
One simple way of doing it is:
cat polls.csv |sed -s "s/.*,//"
sed -s "s/.*,//" replaces everything before last comma with nothing, hence leaving polling organisation.
For your second question, you can continue to use sort -u
which will sort everthing uniquely and then do wc -l
to count, for example:
cat polls.csv|sed -s "s/.*,//"|sort -u|wc -l
For consonant check, it is a separate problem definition. There are many ways to check it. Here's my way on top of my head:
# /bin/python
import sys
import re
consonants = "bcdfghjklmnpqrstvwxyz"
def count_consonants(word):
count = 0
for x in word:
if x in consonants:
count += 1
return count
while True:
line = sys.stdin.readline()
if line:
line = line.rstrip()
line = re.sub(" +", " ", line)
words = line.split(" ")
for w in words:
c = count_consonants(w)
if c >= 6:
print w
else:
break
Please save it as script.py
and Then do it:
cat polls.csv|sed -s "s/.*,//"|sort -u|python script.py
or
cat words|python script.py