If file foo contains 9 lines, each of which is the one-digit line number of the line in the file (1 through 9), what is the output on your screen of this command:sort foo foo | tail -2 | head -1The answer is 9 but what I don't understand is how they got it.What does the sort command actually do?Likewise, if foo contains 99 lines, each of which is the two-digit line number of the line in the file (01 through 99), what should be the output of this command:sort -r foo foo | tail -4 | head -1
how to find the output for a file if head number and tail number is given
sort;tail;head
As stated in the manual sort sort[s] lines of text files. This is clearly a trick question to test basic knowledge and not to accomplish anything. as tail -1 foo has the same output.> echo -e 1\n2\n3\n4\n5\n6\n7\n8\n9 > foo> sort foo123456789> sort foo foo112233445566778899> sort foo foo | tail -299> sort foo foo | tail -2 | head -19if you missed that foo was passed twice you might think the answer 8 or if you had no idea what any of the commands did you would not be able to answer the question beyond guessing.