Assessment: Pipes and Filters

Oct 1, 2014 • Logan Cox

The following two activities are based on the Pipes and Filters lesson.

Ex 1. Beginning with the animals.text file from the lesson which contains the following lines:

2012-11-05,deer
2012-11-05,rabbit
2012-11-05,raccoon
2012-11-06,rabbit
2012-11-06,deer
2012-11-06,fox
2012-11-07,rabbit
2012-11-07,bear

Which of the following commands will create a new file containing only the non-deer entries sorted in descending date order?

a) grep -v deer animals.txt | sort -r  > out.txt
b) grep -v deer animals.txt > sort -r | out.txt
c) grep -v deer <code>--sort -r animals.txt  out.txt</code>
d) grep -v deer animals.txt | sort out.txt

**Ex 2. ** Along with animals.txt, assume that you have two additional files: minerals.txt and vegetables.txt. Like animals.txt, each line of both of these files consists of two fields, a date and a text key.  Make a list containing only the text keys from all three files that are associated with the date 2012-11-05, excluding duplicate entries.