LinuxQuestions.org
Help answer threads with 0 replies.
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 09-21-2010, 04:49 AM   #1
mcgiwer
LQ Newbie
 
Registered: May 2010
Distribution: Ubuntu
Posts: 3

Rep: Reputation: 0
[bash] automatic commenting out lines in file


I would like to create a 2 bash scripts with comment text lines in files.

* first script should check if the entry from this line is somewhere used and if not to comment it out.

* second script should comment all entries with aren't already commented out
 
Old 09-21-2010, 04:59 AM   #2
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,138
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
what is to be commented and what is to be not ?
 
Old 09-21-2010, 09:09 AM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,604
Blog Entries: 25

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Hi,

Quote:
Originally Posted by mcgiwer View Post
I would like to create a 2 bash scripts with comment text lines in files.

* first script should check if the entry from this line is somewhere used and if not to comment it out.

* second script should comment all entries with aren't already commented out
Smells like homework!

So you've shown us your need! What's your deed?


We will aid you when you help yourself to a solution. Provide us with what you have attempted and then maybe someone will be able to assist.

Check out
Bash Reference Manual & Advanced Bash-Scripting Guide.

 
Old 09-21-2010, 09:11 AM   #4
alli_yas
Member
 
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
Post what you've done thus far and we'll help you from there.
 
Old 09-22-2010, 01:18 AM   #5
mcgiwer
LQ Newbie
 
Registered: May 2010
Distribution: Ubuntu
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by onebuck View Post
Smells like homework!

So you've shown us your need! What's your deed?

We will aid you when you help yourself to a solution. Provide us with what you have attempted and then maybe someone will be able to assist.

Check out Bash Reference Manual & Advanced Bash-Scripting Guide.
it's not a home work but for personal use. I asked you for help because I'm not good (yet) in Linux shell programming. And thanks for the links.
 
Old 09-22-2010, 01:40 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,425

Rep: Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826
The links onebuck has provided will point you in the right direction.

If you show us some examples of input and the proposed output I am sure we can help a little further towards your education.
 
Old 09-22-2010, 01:59 AM   #7
mcgiwer
LQ Newbie
 
Registered: May 2010
Distribution: Ubuntu
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by grail View Post
If you show us some examples of input and the proposed output I am sure we can help a little further towards your education.
I wanted to edit this way some configuration files from "/etc" dir, to secure and customize my system
 
Old 09-22-2010, 03:17 AM   #8
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,425

Rep: Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826
Quote:
I wanted to edit this way some configuration files from "/etc" dir, to secure and customize my system
If you simply wish to edit the files then use your favourite editor. If you wish to write a script I think you still need to provide examples.
you do not have to divulge any sensitive information, just make up a file and provide a before and after snapshot.
 
  


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] Function for block commenting bash scripts in gedit idaham Linux - General 7 04-10-2010 04:46 PM
Basic bash script question re: file size or # of lines in a file the_fornicator Programming 6 09-03-2009 10:41 AM
bash - question about commenting babag Programming 5 09-20-2008 12:33 PM
[bash] edit lines in a file pieperp Programming 4 01-31-2007 09:56 AM
VIM finding and commenting lines shamgar03 Linux - Software 3 06-06-2006 05:49 PM


All times are GMT -5. The time now is 12:12 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration