makansij
makansij

Reputation: 9865

How to delete lines in a ".data" file?

I have an enormous file, about 10 MB, and it has about 175,000 lines. I tried truncated it like this:

sed '500,175000d' <file-name.data>

I reopen the file, and all of the lines are still there! I tested this with other files and it works. For some reason the .data extension doesn't work? How do I delete these lines?

Upvotes: 0

Views: 55

Answers (1)

Tom
Tom

Reputation: 54

You need to either redirect the output to a new file like

sed '500,175000d' file-name.data >newFile

or use the edit in place option which rewrites the input file

sed -i '500,175000d' file-name.data

as pointed out by Wintermute

Edit:

A faster sed would be just

sed -i '500q' file-name.data # prints 1-500 and quits after line 500

Upvotes: 1

Related Questions