Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

Print nth line bash

# Format, where n is the nth line
sed -n '0~Np'

# For example, to copy every 5th line of oldfile to newfile, do
sed -n '0~5p' oldfile > newfile

# would print lines 2, 7, 12, 17, 22, 27, …, up to the end of the file.
sed -n '2~5p' oldfile
Source by unix.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #Print #nth #line #bash
ADD COMMENT
Topic
Name
2+9 =