LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-19-2012, 11:51 PM   #1
johnabraham
LQ Newbie
 
Registered: Dec 2012
Posts: 19

Rep: Reputation: Disabled
how to comment multiple statement?


Hi

I want to comment multiple lines in any config file, how can i do it? is there any solution?

thanks
 
Old 12-20-2012, 12:11 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,264

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
What does the cfg file look like? What syntax does it use for commenting? Is this in eg vi/vim, or do you need a programmatic soln eg sed?
 
Old 12-20-2012, 04:24 AM   #3
johnabraham
LQ Newbie
 
Registered: Dec 2012
Posts: 19

Original Poster
Rep: Reputation: Disabled
i want to comment multiple lines in DHCP config file. as we comment multiple lines by /* */ in c.
 
Old 12-20-2012, 05:33 AM   #4
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: /root
Distribution: Slackware & BSD
Posts: 1,213

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by johnabraham View Post
i want to comment multiple lines in DHCP config file. as we comment multiple lines by /* */ in c.
/* this is comment in C */

# this is comment in unix scripts running in bash or csh #

They call it # pound # that's what we use to comment on most Gnu/Linux/*nix config files as they are found in /etc directory; and since it is line oriented one comment at the beginning of the line is good until the end.

Example:

# if [ "$1" = "stop" ]; then
# echo "Stopping gpm..."
# /usr/sbin/gpm -k
elif [ "$1" = "restart" ]; then
echo "Restarting gpm..."

The 'if', 'echo' and '/usr...' lines are commented and not read; the elif is read and subsequent.

Hope that helps.

Good luck.

Last edited by malekmustaq; 12-20-2012 at 05:39 AM.
 
Old 12-20-2012, 07:27 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
I suggest you first do a search or two of past archives and/or the web and see how other people have handled the same kind of problem. Also, sed is the most common tool for this kind of job, so try looking up how to use it.

Second, we're not here to do your jobs for you, but we will help you if you have specific problems. Show us what you have attempted on your own, and we'll be happy to guide you through your problem areas.

Finally, and more generally, if you want clear answers you have to provide clear questions. Explaining your situation and environment in detail and providing a representative example of the text you have, and how you want it to look afterwards, will help us understand the problem as you see it, and give you the most useful advice possible.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] I need an awk statement that will look for the home directory and comment it out. Thaidog Programming 12 04-17-2012 06:48 AM
multiple expression if statement s_linux Suse/Novell 4 02-11-2012 08:02 AM
[SOLVED] if statement with multiple tasks ted_chou12 Linux - Newbie 3 02-02-2011 06:59 PM
comment multiple lines in vim Furlinastis Slackware 9 12-11-2007 01:01 PM
how to recognize a multiple line comment ? cyu021 Programming 2 04-07-2005 09:44 AM


All times are GMT -5. The time now is 09:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration