skip to content
Notes && Anecdotes
A decorative, semi-related stock photo that adds less value than this comment.

grep middle of file (unix)

bashgrep

How to grep tails and head

# gives first lines 1-1000 lines
head -1000 file.txt

# gives the last 1000 lines
tail -1000 file.txt

# gives all lines from 1001 -> last line
tail +1000 file.txt

# gives lines 1001-2000
head -2000 file.txt | tail -1000

# gives lines 1001-2000
tail +1000 file.txt | head -1000