head -N filePrint the last N lines
tail -N filePrint all EXCEPT the first N lines
tail +$((N+1)) filePrint all EXCEPT the last N lines
head -n -N filePrint lines N to M (inclusive)
sed -n 'N,Mp' filePrint line N
sed 'Nq;d' filePrint all EXCEPT line N
sed 'Nd' filePrint multiple lines, I, J, K etc
Assuming I > J > K:
sed 'Ip;Jp;Kq;d' fileThe last
q
tells sed
to quit when it reaches the Kth line instead of looping over the remaining lines that we are not interested in.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.