In bourne, ksh, bash, etc, everything between a # and the newline is ignored. This includes a terminal backslash. But you can have as many comment lines as you want. Just start each one with a #.
There is a kludgy way of doing it
i.e. everything between : ' and ' will be ignored. This will fall over if you have single quotes inside the "commented" area.
Originally posted by zazzybob There is a kludgy way of doing it
That actually has side effects that may not be obvious. In the original Bourne shell that was the only way to comment code. If you look at the original csh man page you see:
Quote:
If neither of the above conditions holds, the kernel cannot overlay the file and the execve( ) call fails (see exec(2)). The C shell then attempts to execute the file by spawning a new shell, as follows:
* If the first character of the file is a #, a C shell is invoked.
* Otherwise, a Bourne shell is invoked.
Bill Joy, the author of csh, explained that he figured a script would always start with a comment and csh used # for comments while sh used : for comments.
The trouble was that : didn't work that well. So Steve Bourne copied the # idea from csh and added it to the Bourne shell. If you follow ZB's syntax exactly, you will sidestep most of the problems that arose from the : comment syntax. These were mostly unintended fd effects like this:
: > /some/important/file
or unintended variable effects like this:
: ${variable:=garbage}
But : is a command and it will succeed. This will set $? and I don't see a way to avoid that. This will work unexpectedly with most sh descendants:
Also there is a performance consideration. The : command cannot be ignored like a # comment can. The arguments to : must be evaluated in case those side effect are desired.
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)
Hi,
I need to comment the below lines in a file using sed.These are the few lines of the jsp file that need to be commented.
if(top.location != location){
top.location.href = location.href;
}
Using the below command two lines can be commented:
if(top.location != location){
... (9 Replies)
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)
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)
Hi ,
I have a XML file like this
<dependency>
<groupId>fr.xxxx.portail.ear</groupId>
<artifactId>_xxxEAR</artifactId>
<version>1.0.0-20xxxxx.xxxxx-x</version>
<type>ear</type>
</dependency>
I need to comment single/multiple lines from XML file.
How can i... (6 Replies)
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)
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... (3 Replies)