Last Updated: February 25, 2016
·
1.427K
· Chao Yang

Print lines in Bash.

Some tips for print lines in Bash.

print first few n lines

head -n n file

awk 'FNR <= n' file

sed -e nq file

sed nq file

print last few n lines

tail -n n file

print a specific line

sed -n 'np' file

print a range of lines n to m

sed -n 'n,mp' file