ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to know that how can i search for a word in a file and then comment it or delete it.
I know this command works.
sed 's/word/#word/'g inputfile > outputfile
But the lines in my input file are as under:
zone "abc.com" { ---- This line can be comment
type master; ----- This line repeat again and again in the file
file "abc.txt";
allow-query { any; }; -This line repeat again and again in the file
};
I want to know how can i comment a certain zone. Any help please.
Script will ask me:
Enter a domain: abc.com <- input
output - I don't want it to show me output... I want, When i enter a domain name it should search it into a file called "named.conf" and then comment it as I've done below.
Suppose you wanted to start with a line containing "fred", and end with a line containing "lulu". Within this range, you want to add "#" to the beginning of each line:
When using an address range, it will start at the first occurence of address1 and end on the first occurence of address2. In your example, you can simply change the second address to "^};" meaning "};" at the beginning of the line.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.