View previous topic :: View next topic |
Author |
Message |
beowulf Apprentice
Joined: 07 Apr 2003 Posts: 225
|
Posted: Tue Jun 03, 2003 6:30 am Post subject: QuickTip: Posting Config Files On The Forum |
|
|
QuickTip: Posting Config Files On The Forum...
I've noticed quite a lot of posts where a user posts their config file in it's entirety (sp?). Not only is there a lot of un-needed information there, it makes the post larger than it needs to be, thus increasing DB query time, page load time and bandwidth to serve a page.
When posting config files, there is usually a very large section that is commented... when posting your config files, save on the space used in the forum's DB and reader's scrolling.
To generate your config file, try this out:
Code: | grep -v "^#" [filename] |
As an example, let's grep the make.conf file which is littered with comments.
Code: | grep -v "^#" /etc/make.conf |
As you can see, the output is far less than what it would be should you copy and paste the entire config file into your post.
You can do this with any commented file.. what about a file that uses semi-colons ";" as coments. here's how it looks:
Code: | grep -v "^;" [filename] |
As you can see, the amount of information you post is far less... how much less? here's an example... My /etc/make.conf file is 12291 bytes. My grep'd make.conf file is 597 bytes. That's a saving of 11 kilobytes! Now imagine 100 unique page views on that page. That's 1.11 Megabytes we've saved. Again, multiply that by say an average of 10 posts like this per week, we've saved 11 megabytes of bandwidth... Resource usage is saved like this as well (cpu cycles, disk usage, memory)... Although the example is extreme, every little bit helps in my opinion....
Just a quick tip that may help you help the server...
[edit: fixed a few grammatical/spelling errors /] _________________ I have nothing witty to say here... ever
Last edited by beowulf on Sat Jun 07, 2003 8:48 am; edited 1 time in total |
|
Back to top |
|
|
dberkholz Retired Dev
Joined: 18 Mar 2003 Posts: 1008 Location: Minneapolis, MN, USA
|
Posted: Tue Jun 03, 2003 3:55 pm Post subject: |
|
|
Great tip. Everyone ought to do this, and you've made it even clearer. |
|
Back to top |
|
|
duff Guru
Joined: 19 Jun 2002 Posts: 466 Location: Clemson, SC
|
Posted: Tue Jun 03, 2003 5:14 pm Post subject: |
|
|
Just to take this a step further, after the grep you can pipe it into sed to remove any intial blank lines and reduce 2 or more consecutive blank lines into 1.
Code: | grep -v "^#" [filename] | sed '/./,/^$/!d' |
Save your scroll wheel some work! |
|
Back to top |
|
|
water Guru
Joined: 19 Jun 2002 Posts: 387 Location: Zierikzee, The Netherlands
|
Posted: Fri Jun 06, 2003 4:58 am Post subject: |
|
|
Nice
i was just thinking about a little script to cleanup config-files. This is some very usefull input. _________________ Groeten uit Holland |
|
Back to top |
|
|
bsolar Bodhisattva
Joined: 12 Jan 2003 Posts: 2764
|
Posted: Fri Jun 06, 2003 5:19 am Post subject: |
|
|
Thanks for trying to help the forums.
If I can add, another problem is that it's not possible to wrap a line without whitespaces. This causes sometimes very wide pages and the need of scrolling horizontally and it's very annoying. _________________ I may not agree with what you say, but I'll defend to the death your right to say it. |
|
Back to top |
|
|
beowulf Apprentice
Joined: 07 Apr 2003 Posts: 225
|
Posted: Fri Jun 06, 2003 5:37 am Post subject: |
|
|
Thanks for that sed line! i made it an easy to type script now... called confviewer hehe... It's not very flexible... but it saves me from typing all that stuff...
Code: |
#!/bin/bash
if [ "$2" == '' ]
then
grep -v "^#" $1 | sed '/./,/^$/!d'
else
grep -v "^$2" $1 | sed '/./,/^$/!d'
fi
|
Probably not the best, but it works...
Code: |
$ confviewer ~/.wine/config ";"
$ confviewer /etc/make.conf
|
_________________ I have nothing witty to say here... ever |
|
Back to top |
|
|
water Guru
Joined: 19 Jun 2002 Posts: 387 Location: Zierikzee, The Netherlands
|
Posted: Fri Jun 06, 2003 6:01 am Post subject: |
|
|
I think it would be a good idea to save the original file. _________________ Groeten uit Holland |
|
Back to top |
|
|
red_over_blue Guru
Joined: 16 Dec 2002 Posts: 310
|
Posted: Fri Jun 06, 2003 6:23 am Post subject: |
|
|
grep and sed don't change the file. If you wanted to, you could do something like:
Code: |
grep -v "^#" /etc/make.conf > /etc/make.conf.new
|
and then look at it, decide for sure you want it, and replace /etc/make.conf with /etc/make.conf.new |
|
Back to top |
|
|
water Guru
Joined: 19 Jun 2002 Posts: 387 Location: Zierikzee, The Netherlands
|
Posted: Fri Jun 06, 2003 6:46 am Post subject: |
|
|
red_over_blue wrote: | grep and sed don't change the file. If you wanted to, you could do something like:
Code: |
grep -v "^#" /etc/make.conf > /etc/make.conf.new
|
and then look at it, decide for sure you want it, and replace /etc/make.conf with /etc/make.conf.new | Uh, yepz
I was thinking about the idea to clean up the config-files on your own computer. _________________ Groeten uit Holland |
|
Back to top |
|
|
duff Guru
Joined: 19 Jun 2002 Posts: 466 Location: Clemson, SC
|
Posted: Fri Jun 06, 2003 12:23 pm Post subject: |
|
|
bsolar wrote: | If I can add, another problem is that it's not possible to wrap a line without whitespaces. This causes sometimes very wide pages and the need of scrolling horizontally and it's very annoying. |
Code: | # <grep'n'sed> | fold -w 60 -s |
That should take care of it...60's good line length for people with low resoultion, isn't it? |
|
Back to top |
|
|
|