this command displays the second line of the file :
cat myfile | head -2 | tail -1
My file contains the following data :
hello
mark
this is the head line
this is the first line
this is the second line
this is the last line
the command above prints the data as: mark
But i am unable to understand this because, head -2 is used to print the first two lines and tail -1 prints the last line but how come 2nd line is printed!!???
tail displays the last line of the head output and the last line of the head output is the second line of the file.
Output of head (input to tail):
Output of tail: