Using Sed to cut out lines or pull out lines

SED Tricks

Using Sed to cut out lines or pull out lines

If you have a text file containing some text

1
2
3
4
5
6
7
8
9
10

And you wanted to deleted lines "3" to "7" out, you can do the following with Sed

sed 3,7d test > test2

This would leave you a new file with

1
2
8
9
10

Now lets say you didnt want to delete the text but wanted to pull out the lines from "3" to "7" then you could do this with sed:

sed -n '3,7p' < test > test2

This would pull out lines "3" to "7" and place in file called "test2"


Browse Space

- Pages
- News
- Labels
- Attachments
- Bookmarks
- Mail
- Advanced

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

 

Other Features

Add Content

- Add Comment