commenting more then 1 line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting commenting more then 1 line
# 1  
Old 12-14-2006
commenting more then 1 line

Hi all,

I m new for linux ... but now i will do this continuously. So my question is how to comment more then 1 line i dont wanna put # to each line.. my script is too big...

or u can tell me that how can i add # to sellected lines means if i wanna put # from line number 10 to 20 then how can i do.. this will also help me...

Thanks
Ajay
# 2  
Old 12-14-2006
Wrap the lines within :<<MARKER.. MARKER like shown below

Instead of MARKER you can use any string which is not used in your script. Preferably a unique string.

Code:
:<<COMMENT
a line in the script.
another line in the script
.
.
yet another line in script.
COMMENT

The above is the easiest thing to do. Else within vi you could issue
Code:
:10,20s/^/#/g

# 3  
Old 12-14-2006
Code:
sed "10,20 s/^/#/" file > tmp
mv tmp file

# 4  
Old 12-14-2006
Thanks !!

Thanks Vino and Anbu.. Thank u very much to both of u..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Commenting a line matched with a specific string in a file

Hi, I would like to comment a line that matched a string "sreenivas" in a file without opening it. Thanks in advance. Regards, Sreenivas (3 Replies)
Discussion started by: raosr020
3 Replies

2. Shell Programming and Scripting

Commenting a specific line and inserting a new line after commented line.

Hello All, I have following file contents cat file #line=aaaaaa #line=bbbbbb #line=cccccc #line=dddddd line=eeeeee #comment=11111 #comment=22222 #comment=33333 #comment=44444 comment=55555 Testing script Good Luck! I would like to comment line line=eeeeee and insert a new line... (19 Replies)
Discussion started by: manishdivs
19 Replies

3. UNIX for Dummies Questions & Answers

Commenting multiple lines

Hi, Can anyone let me know how to comment multiple lines in VI editor? Many thanks. Regards, Venkat. (3 Replies)
Discussion started by: venkatesht
3 Replies

4. Shell Programming and Scripting

commenting out lines between two delimiters

Hi All, I am struggling to get my head around the following issue. I am having to comment out lines between two delimiters by placing an asterix in position 7 but retain all lines in the file and in the same order. so for example a file containing: ... ... DELIM1 ... ... DELIM2... (2 Replies)
Discussion started by: Bruble
2 Replies

5. Shell Programming and Scripting

Commenting lines

Hi can any body pls help me : I have a file Which Content is like following: p3:s1234:powerfail:/usr/sbin/shutdown -y -i5 -g0 >/dev/msglog 2<>/dev/msglog ca:3:respawn:/opt/GoldWing/currentPM/local/critagt > /dev/msglog 2<>/dev/msglog ca:3:respawn:/opt/GoldWing/currentPM/local/startcia.sh... (2 Replies)
Discussion started by: Aditya.Gurgaon
2 Replies

6. Shell Programming and Scripting

Commenting contab from a script

Dear All, I have many cron entries and want to comment a particular cron entry from a script. Ex- Suppose I have the below cron entries: # DO NOT EDIT THIS FILE - edit the master and reinstall. #Cron entries for Jboss server 1 0 23 * * * /usr/bin/echo 0 23 * * * /usr/bin/asdg_count.sh 0 23 *... (5 Replies)
Discussion started by: avishek007
5 Replies

7. Shell Programming and Scripting

commenting

can we use "---------" for commenting......... (2 Replies)
Discussion started by: simmijaswal
2 Replies

8. Shell Programming and Scripting

Commenting a Line In a File

HI all I am working on a script, few details are as follows. I have one properties File and one script. The property file contains the JOBID which are to be executed and the Script runs these jobs ONE by ONE. After completing the JOB I need to comment that job in the property File. This is the... (3 Replies)
Discussion started by: Prashantckc
3 Replies

9. Shell Programming and Scripting

Commenting

How can i comment multiple lines in unix ..............shell script. (6 Replies)
Discussion started by: dreams5617
6 Replies

10. UNIX for Dummies Questions & Answers

Commenting lines

How to comment a set of lines in a script? we use # to comment a single line , is there ant other cmd to comment a block? (2 Replies)
Discussion started by: rolex.mp
2 Replies
Login or Register to Ask a Question