Extract Numbered Lines from a File with sed

Easy if you can ever remember the magic syntax:

sed -e 'AAA,BBB!d' file.txt

… where AAA and BBB are 1-based line numbers, and the range is treated inclusively.

Questions or comments? For better or worse this website isn’t interactive, so send me an email or, uh, Toot me.

To get notified of new posts, try subscribing to my lightweight newsletter or my RSS/Atom feed. No thirsty influencering — you get alerts about what I’m writing; I get warm fuzzies from knowing that someone’s reading!

See a list of all how-to guides.

On GitHub you can propose a revision to this guide or view its revision history.