sed command example - extract lines from a file

Although I've written my own Perl program to extract lines from the middle of a file, I was just reminded that this can be done with the Linux sed command.

Here's a simple sed command example. Supposed you want to print lines 500 through 600 from a file named reallyBigFile.txt. Just issue this command and you'll get what you want:

sed -n '500,600p' reallyBigFile.txt

 

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.