We have already met the head
command, which prints lines from the start of a file. tail
is similar, but prints lines from the end of a file instead.
Consider the file shell-lesson-data/data/animals.txt
. After these commands, select the answer that corresponds to the file animals-subset.txt
:
$ head -n 3 animals.txt > animals-subset.txt
$ tail -n 2 animals.txt >> animals-subset.txt
animals.txt
animals.txt
animals.txt
animals.txt
head
command. For option 2 to be correct we would only run the tail
command. For option 4 to be correct we would have to pipe the output of head
into tail -n 2
by doing head -n 3 animals.txt | tail -n 2 > animals-subset.txt