Display every nth line in a file in Linux bash

Home > Search
  by

Let's say file.txt contains the following text.

Hello
Hello
Hello
World
World
World

 

The following sed command can be used to remove every nth line, such as every second line, or every third time.

~]# cat file.txt | sed -n -e 3p
Hello
World
How
are
you
today?

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments