I got tired of searching through long config files which have loads of comments looking for some option I'd set. It also annoys me when someone posts their huge config files which are mainly comments, not only does it take up valuable database space it also makes it harder to see what the problem is.

So I wrote a small script called confcat which will just show you the important parts of your config files.

Edit: made it so it includes comments that appear after whitespace at the beginning of the line, lines that only have whitespace and so that it only uses one grep process_________________Search | Read | Answer | Report | Strip

Last edited by tomk on Fri Nov 24, 2006 11:59 pm; edited 2 times in total

Nice, I've been thinking of something like this for a while after going trough some XF86Configs generated with fglrxconfig, containing 95% comments, I've been to lazy to try to do anything myself though _________________God apa gavs galna anlag svag apa dog

I do the same thing with a perl script i whipped up one night to take the comments out of my kernel .config.

Code:

#!/usr/bin/perl
while(<>) {
print unless m/^#/ or m/^\s+/;
}

EDIT:
Mine's not as cool as yours though as it only removes comments at the beginning of the line _________________Never try to explain computers to a layman. It's easier to explain sex to a virgin.
-- Robert Heinlein

While my script works fine for kernel configs, it doesn't work for X configs because i foolishly remove every line that starts with whitespace Here is my new and improved version that works by anchoring the whitespace to the whole line:

Code:

#!/usr/bin/perl
while(<>) { print unless m/^#/ or m/^\s+$/; }

Now i feel better _________________Never try to explain computers to a layman. It's easier to explain sex to a virgin.
-- Robert Heinlein

Not meaning to wake up the dead here, but wouldn't it just be easier to put this as an alias in your /etc/profile ? eg

Code:

alias confcat="sed -e 's/#.*//;/^\s*$/d' "$@""

and you can still run it the same way as if you'd put it in a script and chmodded it and all, but it just saves you from having to make another executable file._________________2b || !2b
{ STFF } { GOOGLE } { RTFM } { NO -U } { STRIP }

emerge info sux, it also shows things that arent even present in the make.conf, that creates a lot of confusion_________________In 2010, M$ Windows will be a quantum processing emulation layer for a 128-bit mod of a 64-bit hack of a 32-bit patch to a 16-bit GUI for an 8-bit operating system written for a 4-bit processor from a 2-bit company that can't stand 1 bit of competition.

emerge info sux, it also shows things that arent even present in the make.conf, that creates a lot of confusion

That may be so, but those things that are added are needed for proper debugging / help purposes. For example, it shows your currently running kernel, installed gcc and glibc, as well as automake / autoconf and your baselayout. Tell me how those are "bad" things that are shown?

For instance Not every user "knows" that certain versions of the (now old) KDE3.2 betas had trouble with the ARCH version of autoconf or automake, so when they posted questions, they get a faster answer if they include the output from emerge --info, which shows what version they're using, and thus allows the person replying to simply say "Upgrade auto* to ~ARCH"

And for the record, I answerd my own earlier post asking if it could be used as an alias. It can, and works just the same (atleast with the one ecatmur posted)_________________2b || !2b
{ STFF } { GOOGLE } { RTFM } { NO -U } { STRIP }

emerge info sux, it also shows things that arent even present in the make.conf, that creates a lot of confusion

Most of the things that emerge --info shows which aren't present in make.conf are defaults which are tucked away in other files on your box. emerge --info gives you an easy way to get all this information about your system in one simple command.

Shan wrote:

And for the record, I answerd my own earlier post asking if it could be used as an alias. It can, and works just the same (atleast with the one ecatmur posted)

This works just as well, and the sed version seems to be quicker than the grep version. As I said before I really need to learn more sed._________________Search | Read | Answer | Report | Strip

I've recently started learning/studying SED and GREP thanks to this thread. I'm unsure if this is correct or not but doesn't the following basically accomplish stripping out "commented lines" as well as "blank ones" in a shorter amount of key strokes? Please let me know what I'm missing here.

Code:

cat .config | sed '/^#/ d' | sed '/^$/ d'

cat .config | sed -e '/^#/ d' -e '/^$/ d'

cat .config | grep '.' | grep -v '#'

cat .config | grep -v '#' | grep '[^$]'

And ecatmur, I would just like to say thanks for the awesome work on the "dep script" here. You have seriously motivated me to start learning the power of the BASH.
There have been so many things that I would like to fix or (actually), make better for myself and possibly the Gentoo community. But things seem to all of the sudden start becoming understandable for what ever reason. Your inspirational and make Linux truely that much more fun.

I feel like I'm starting to break some wild horse.. Not there yet. But I know if I stick with it and have good teachers like you guys/gals I'll get there.. Trying to stay focused in one Linux area over another seems to be my biggest problem. Kid in the candy store effect.

And ecatmur, I would just like to say thanks for the awesome work on the "dep script" here. You have seriously motivated me to start learning the power of the BASH....
...You're inspirational and make Linux truely much more fun....

I would like to step in line to this. As I am a noob "chmod 755" gave me just the tip I needed. Not knowing how to execute a script. And the rest speeks for it self.