Search

To view lines in the middle of a file

The command "head" is used to view the top lines of a file and command "tail" is used to view lines at the end.

What if we want to view the lines in between, that is neither from the top nor from the bottom.

For example let us say we have a file with the following contents:

file1 :



We can use the head command to view the top 3 lines



We can use the tail command to view the bottom 3 lines



But how to view the 3 lines in the center. Here are two ways of doing it.

Using a combination of head and tail



Using awk



1 comment:

  1. A relevant post on Linux which I was actually looking for. It will be beneficial for my work to do better. You should seldom how to refill canon ink cartridges for better work.

    ReplyDelete