LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-18-2011, 11:16 PM   #1
ramlubhai
LQ Newbie
 
Registered: May 2011
Posts: 2

Rep: Reputation: Disabled
Smile Cleaner, Neater Configuration files


Not exactly new to Linux but - over the years I have been appalled to find hundreds of configuration files for every known program/service in Linux with millions of lines of useless comments that you have to endlessly scroll up-and-down in a text-editor to find anything of value and then make sense of what you need to configure/change, etc.

Is there an automated way to clean up any given configuration file and get rid of the "filler" stuff ??

Seems like a shell script should be able to accomplish the task by getting rid of all lines that start with # ..

Thanks.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 05-19-2011, 12:13 AM   #2
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by ramlubhai View Post
Seems like a shell script should be able to accomplish the task by getting rid of all lines that start with # ..
grep -v '^#' dirty > clean
 
Old 05-19-2011, 12:19 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
And empty lines:
Code:
grep -v "^#" < config.verbose | grep -v "^$" > config.terse
 
Old 05-19-2011, 12:21 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Is this a troll?... because I'm tempted to bite.
You must be a pretty smart person to think that the comments someone took the time to write are merely obfuscating the information. I've always viewed the ability to heavily comment configuration files as beyond good, but crucial. Do you save wasted disk space by deleting the man pages, too?
Looks like I have bitten...
--- rod.
 
Old 05-19-2011, 02:16 AM   #5
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
Originally Posted by catkin View Post
And empty lines:
Code:
grep -v "^#" < config.verbose | grep -v "^$" > config.terse
Hmmm, a better idea might be to pipe the output to 'less' rather than create a new file (although that doesn't seem to be what the OP was asking for). That way you have a transient version that gives a quick summary.

OTOH, I've just tried it on an arbitrary but unfamiliar conf file, and it renders the file virtually unreadable (incomprehensible). Virtually unreadable, though compact, so scrolling is quicker, although, arguably, I might like it better on a conf file that I knew well. Maybe. You pays your money and you takes your choice, I suppose.
 
Old 05-19-2011, 02:47 AM   #6
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
your solution is here: http://www.debian-administration.org...guration_files
Actually what i love is how they hide comments in vim without actually removing them. So you get the best of both worlds:
compact view that lets you view only the active lines, but at any time you can get any comment back. And if you save the document, the comments are untouched.

I just tried this in gvim which adds mouse support to vim, vim itself extending vi.
 
4 members found this post helpful.
Old 05-19-2011, 03:26 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by theNbomr View Post
You must be a pretty smart person to think that the comments someone took the time to write are merely obfuscating the information. I've always viewed the ability to heavily comment configuration files as beyond good, but crucial.
For me they are crucial when the configuration is unfamiliar but do prevent "seeing the wood for the trees" when it's familiar. I always keep the original (typically renamed with a .org suffix) and, for heavily commented files, strip the comments. A benefit of this scheme is that searching for *.org files (and directories in the case of directories in which every file is used to configure) identifies all the configurations which have been customised since installation.
 
Old 05-19-2011, 03:27 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Thanks for the link 16pide Vim's hiding feature is new to me.
 
Old 05-19-2011, 07:32 AM   #9
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,922
Blog Entries: 44

Rep: Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158
Hi,

With today's hdd density I cannot see the reasoning behind removal of text comments within configure files.
Even before the higher disk density I would not remove comment text from configure files. Too many, plus there is no way that you could remember the conditions for all files. I have files that were written years ago and thankfully comments were there to refresh my memories.

You really should go through the vi tutorial.

So I guess the OP caught another one!
 
Old 05-19-2011, 07:33 AM   #10
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,922
Blog Entries: 44

Rep: Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158
@OP Welcome to LQ!
 
Old 05-19-2011, 08:50 AM   #11
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by onebuck View Post
With today's hdd density I cannot see the reasoning behind removal of text comments within configure files.
Even before the higher disk density I would not remove comment text from configure files.
The reason the OP wanted to remove comments is not because of HDD space, but because they're hard to scroll through in an editor.
 
Old 05-19-2011, 09:02 AM   #12
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,091

Rep: Reputation: 41
this should be a good note to the software devs, most people dont like commented config files... if we want the commenst we will type man someapp.conf
 
Old 05-19-2011, 09:08 AM   #13
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
I personally am a great fan of commented config-files. Since it is so easy to strip out the comments, or fold them in vim, I see no reason to get rid of the comments in standard configuration files.
 
Old 05-19-2011, 09:14 AM   #14
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
It is nice to strip the comments and blank lines when posting on LQ ... ?
 
Old 05-19-2011, 09:21 AM   #15
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by catkin View Post
It is nice to strip the comments and blank lines when posting on LQ ... ?
I agree with that, makes it easier to read them.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
windows registry cleaner bigearsbilly General 13 03-03-2011 06:33 AM
Firefox Cleaner mlpa Linux - Software 2 08-01-2009 05:14 PM
Text Cleaner nlavon Linux - Software 2 06-10-2008 06:32 AM
Is there a neater way to do this? (bash script) Freemor Programming 8 04-02-2006 02:33 PM
MRU cleaner Ageless Linux - Software 0 04-26-2005 12:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:10 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
Open Source Consulting | Domain Registration