Technology TidBits

Answers to various technical questions on php programming, mysql, linux, and many more categories.
25% off Hosting at HostGator.com:
Use Code techbits25



How can I save part of a file to a new file in vi?

Last updated: 05/21/2012

Sometimes it's nice to be able to pull out a piece of code or text from a file and save it to a new file.  Maybe you just need lines 48-105 of a file and want to easiyl extract that. 

In vi, you can do the following while editing the file:

:48,105w smallerfile.txt

this will save the lines 48-105 to the "smallerfile.txt"

blog comments powered by Disqus
Have your own Tech-bit to contribute? Submit it here

Other questions in this category:
How do I set Tab stops in VI?
How can I turn on line numbering in Vi?
How can I jump to a line in the vi editor?
How can I remove DOS linebreaks (^M) from my files?
How can I remove leading whitespace in all lines in a file using vi?
How can I delete a large chunk of text using vi?
How can I undo and redo changes in vi?
How can I search in the vi editor?
How can I set a mark to remember my spot in vi?
How can I 'undo' an 'Undo' in VI?
How do I stop pasted text from indenting / wrapping when I right-click in vi?
How can I get vi to indent automatically when I'm programming in c or php or perl?
Prevent pasted text from indenting/wrapping in vi - alternate method



Powered by KnowledgebasePublisher 1.1
Host Gator
Content provided by Roberts WebForge, Inc.