multiline comment in shell script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers multiline comment in shell script
# 1  
Old 03-31-2011
multiline comment in shell script

Is thery any way to give comment to multiple line without explicitly specifying # at the begining of each line ?
# 2  
Old 03-31-2011
Afaik no. You can help yourself with maybe putting multiple lines into a function, that will never be called. Let's say we want to "comment" cmd3-5:

Code:
cmd 1
cmd 2
dummy()
{
cmd 3
cmd 4
cmd 5
}
cmd 6

Since function dummy will never be called, you will have the effect you are asking for. As with # commented lines, you have to care for correct syntax like if/then/fi, case/esac, while/do/done, for/do/done, and so on.
These 2 Users Gave Thanks to zaxxon For This Post:
# 3  
Old 03-31-2011
You can also try this:

Code:
cmd 1
cmd 2
: || : << END_OF_COMMENT
cmd 3
cmd 4
cmd 5
END_OF_COMMENT
cmd 6

In this case you don't have to care about correct syntax in the commented out section.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Multiline html tag parse shell script

Hello, I want to parse the contents of a multiline html tag ex: <html> <body> <p>some other text</p> <div> <p class="margin-bottom-0"> text1 <br> text2 <br> <br> text3 </p> </div> </body> (15 Replies)
Discussion started by: SorcRR
15 Replies

2. Shell Programming and Scripting

Shell Script Comment code blocks in a bash source file

Just began to learn on Shell Script. I got an exercise from my friend. I know how to make this happen in C, but I'm not familiar with Shell Script. Hope I can get some help from all of you. I want to write a bash script to comment code blocks in a bash source file. What I mean comment is '#', I... (1 Reply)
Discussion started by: HiFuture0801
1 Replies

3. Shell Programming and Scripting

How to create multiline csv cell through shell script?

Hi, I have a text like the one given below status="Observation 1" read1="Source rows not load" read2="Score drop" I want to create a csv and mail it out in such a way that all three lines will be in a single cell but as three lines. For ex Col C1 ... (3 Replies)
Discussion started by: prasperl
3 Replies

4. UNIX for Dummies Questions & Answers

Easiest way to comment/uncomment a shell script?

cd path line1 line2 line3 line4 line5 Lets say thats the sample script...So say if i have to comment the above script, which would be the better way so that whenever i want, i cud comment or uncomment the same. Thanks (1 Reply)
Discussion started by: saggiboy10
1 Replies

5. Shell Programming and Scripting

How to replace word with multiline text using shell scripting.

Hi all I have data files which contain data as shown below: Line 5: FIDE INST_DESC: DIAM Co Ltd/Japan => MAID Co Ltd/Japan INST_NME: DIAM Co Ltd/Japan => MAID Co Ltd/Japan Line 6: FIDE INST_DESC: DIAM DL/Pimco US Bond Open Born in the USA => MAID DL/Pimco US Bond Open Born in the... (6 Replies)
Discussion started by: Ganesh_more
6 Replies

6. Shell Programming and Scripting

how to ignore multiline comment from a file while reading it

Hi friends , I want to ignore single and multiline comment( enclosed by " \* *\" ) of a file whle reading it. I am using the below code. nawk '/\/\*/{f=1} /\*\//{f=0;next} !f' proc.txt | while read str do ... done The problem is its working partially. that is its failing in one... (1 Reply)
Discussion started by: neelmani
1 Replies

7. Shell Programming and Scripting

comment and uncomment a line with Shell Script

Requirement is: 1. comment and uncomment the line with Shell Script: /opt/admin/fastpg/bin/fastpg.exe -c -=NET (using fastpg.exe as a search option) 2. display = "Commented" (when its commented) and display = "Uncommented" (when its uncommented) Its urgent, please let me asap!!! Thanks in... (2 Replies)
Discussion started by: anthonyraj75
2 Replies

8. Shell Programming and Scripting

assigning a multiline grep output which has been piped through sed to a shell variabl

Hi, I wish to format the output of a grep command in such a way that sed will be able to handle the newline characters held in the output. Since sed does not allow newlines to be contained in a replacement pattern, that means adding a backslash '\' character to the end of each line from... (8 Replies)
Discussion started by: timculhane
8 Replies

9. Shell Programming and Scripting

help needed for multiline comment deleting script

Hi I have a script to delete the multiline comments as below ******************************************** #!/usr/bin/sed -f #Replaces single line comment s://.*:: #Replaces multiline comment present in a single line s:/\**\*/::g #Starting of the loop for checking the starting of the... (1 Reply)
Discussion started by: aster007
1 Replies

10. Shell Programming and Scripting

Block Comment in Shell script

how to put multiline comments in a shell script like /* Some code */ in C language? (3 Replies)
Discussion started by: skyineyes
3 Replies
Login or Register to Ask a Question