The file animals.txt
contains 8 lines of data formatted as follows:
2012-11-05,deer
2012-11-05,rabbit
2012-11-05,raccoon
2012-11-06,rabbit
...
The uniq
command has a -c
option which gives a count of the number of times a line occurs in its input. Assuming your current directory is shell-lesson-data/data/
, what command would you use to produce a table that shows the total count of each type of animal in the file?
sort animals.txt | uniq -c
sort -t, -k2,2 animals.txt | uniq -c
cut -d, -f 2 animals.txt | uniq -c
cut -d, -f 2 animals.txt | sort | uniq -c
cut -d, -f 2 animals.txt | sort | uniq -c | wc -l
shell-lesson-data/data
directory).