The comment symbol for Unix scripts is typically “#”. You can use the same concept for files for other programming languages. My vi commands below use the “#” symbol.
If you want to comment 5 lines in a file -
- Go to the first line you want to comment
- Make sure you are in the command mode. (Hit ESC).
- Now type the following “:.,+N-1 s/^/#/g”, Where N is the number of lines you want to comment. In this case it would be
:.,+4 s/^/#/g
You can also comment till a unique word in a file. For instance here is a snippet of a file -
line one line two line three line four line five |
Suppose you want to comment from line two till line four. Go to the beginning of “line two” and type the following after you are in the command mode
:.,/line four/ s/^/#/g |
Related posts:
- Grep for multiple stuff in one file Update: See the comments to see how to do this...
- Unix tar tricks One of the most common programs on Linux systems for...
- Sending email with a body and attachment from UNIX It is easy to send a text file as the...
- Shutdown unused windows service Download the tool from http://www.smartpcutilities.com/ to shutdown services not used...
Related posts brought to you by Yet Another Related Posts Plugin.







Recent Comments