unixtailunix-head

Using combination of "head" and "tail" to display middle line of the file in Unix


If I have a file name myownfile.txt which contains 3 lines of text.

foo
hello world
bar

I want to display the line in the middle which is hello world by using head and tail command only.


Solution

  • head -2 myownfile | tail -1 
    

    should do what you want