 <p>I think piping is what you're looking for: <a href="https://en.wikipedia.org/wiki/Pipeline_%28Unix%29" rel="nofollow">https://en.wikipedia.org/wiki/Pipeline_(Unix)</a></p> <p>To use the first example you gave:</p> <p><code>head +2 filename | head +n</code></p> <p>I believe is what you want, though note that I haven't tested it</p>