home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 30.11 Keep Your Original File, Write to a New File Chapter 30
vi Tips and Tricks
Next: 30.13 Appending to an Existing File
 

30.12 Saving Part of a File

While editing, you will sometimes want to save just part of your file as a separate, new file. For example, you might have entered formatting codes and text that you want to use as a header for several files.

You can combine ex line addressing (33.3 ) with the write command, w , to save part of a file. For example, if you are in the file practice and want to save part of practice as the file newfile , you could enter:

:230,$w  newfile

Saves from line 230 to end-of-file in newfile .

:.,600w  newfile

Saves from the current line to line 600 in newfile .

[After newfile has been created, you'll need w! instead of w . -JP  ]

- LL from O'Reilly & Associates' Learning the vi Editor , Chapter 5


Previous: 30.11 Keep Your Original File, Write to a New File UNIX Power Tools Next: 30.13 Appending to an Existing File
30.11 Keep Your Original File, Write to a New File Book Index 30.13 Appending to an Existing File

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System