View previous topic :: View next topic |
Author |
Message |
jmbsvicetto Moderator
Joined: 27 Apr 2005 Posts: 4735 Location: Angra do Heroísmo (PT)
|
Posted: Tue Feb 14, 2006 7:40 pm Post subject: |
|
|
Congratulations. Those are all very good scripts to strip comments.
All we need now is that users read this thread before posting their config files and remember to use the [ code ] and [ /code ] tags. _________________ Jorge.
Your twisted, but hopefully friendly daemon.
AMD64 / x86 / Sparc Gentoo
Help answer || emwrap.sh
|
|
Back to top |
|
|
Joe User n00b
Joined: 21 Mar 2004 Posts: 10 Location: Germany
|
|
Back to top |
|
|
al Guru
Joined: 26 Dec 2002 Posts: 304 Location: Scotland
|
Posted: Thu Jun 15, 2006 11:40 am Post subject: |
|
|
x1jmp wrote: | Thanks for this tip with sed!
My version is this, which also deletes lines with ";", like the smb.conf
Code: | sed -e 's/[#;].*//;/^\s*$/d' |
It's also possible to add exactly this into the .bashrc as an alias. |
Thanks brilliant!
I've been looking for something to strip the ";" comments out of my Asterisk files while i'm still setting it up.
Thanks.
|
|
Back to top |
|
|
chrismortimore l33t
Joined: 03 Dec 2005 Posts: 721 Location: Edinburgh, UK
|
Posted: Wed Aug 09, 2006 6:13 pm Post subject: |
|
|
All these look very complex...
works for me, and you can replace the "#" for something else if you need to. Althought it doesn't take account of whitespace, but I find 9 times out of 10 it's enough. _________________ Desktop: AMD Athlon64 3800+ Venice Core, 2GB PC3200, 2x160GB 7200rpm Maxtor DiamondMax 10, 2x320GB WD 7200rpm Caviar RE, Nvidia 6600GT 256MB
Laptop: Intel Pentium M, 512MB PC2700, 60GB 5400rpm IBM TravelStar, Nvidia 5200Go 64MB |
|
Back to top |
|
|
tomk Bodhisattva
Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Sat Nov 25, 2006 12:10 am Post subject: |
|
|
Just updated it (only two and a half years late ) so that it takes into account whitespace before a comment, lines that only contain whitespace and so that it uses just one grep process. _________________ Search | Read | Answer | Report | Strip |
|
Back to top |
|
|
bunkacid Tux's lil' helper
Joined: 11 Jan 2005 Posts: 111 Location: Laguna Hills, CA
|
Posted: Tue Dec 19, 2006 1:25 pm Post subject: |
|
|
thanks, i only just found this useful "one liner" to include in my ~/bin |
|
Back to top |
|
|
hielvc Advocate
Joined: 19 Apr 2002 Posts: 2805 Location: Oceanside, Ca
|
|
Back to top |
|
|
nanafunk n00b
Joined: 29 Jun 2005 Posts: 36
|
Posted: Mon Jan 15, 2007 12:48 am Post subject: |
|
|
Code: | [%] cat a
#comment1
#comment2
[%] sed '/^#\|^$/d' a
#comment2
|
|
|
Back to top |
|
|
hielvc Advocate
Joined: 19 Apr 2002 Posts: 2805 Location: Oceanside, Ca
|
Posted: Tue Jan 16, 2007 12:22 am Post subject: |
|
|
Ratsafrats I went back re-read the submissions, and for sed Eds " sed 's/#.*//;/^\s*$/d' "$@" " and x1jmp's sed 's/[#;].*//;/^\s*$/d' it is obvious that they new the great secret of the shortest sed for SIMPLE configs but hide it in supurfluous hyperbole and you fell for it
EDIT In a kind hearted effort, I remove the dangling "-e" form pooor old Eds and x1jmps ostentatious seds. _________________ An A-Z Index of the Linux BASH command line |
|
Back to top |
|
|
thomasvk Guru
Joined: 19 Mar 2005 Posts: 597
|
Posted: Sat Jan 27, 2007 1:03 pm Post subject: |
|
|
A lot of diffent ones,... but which one is the best? |
|
Back to top |
|
|
Sakkath Apprentice
Joined: 06 Nov 2005 Posts: 198 Location: Pawtucket, RI
|
Posted: Fri Feb 09, 2007 1:53 pm Post subject: |
|
|
Maybe `confcat` should go in baselayout _________________ The person who makes no mistakes does not usually make anything.
Please add [SOLVED] to the subject of your original post when you feel that your problem is resolved. |
|
Back to top |
|
|
timeBandit Bodhisattva
Joined: 31 Dec 2004 Posts: 2719 Location: here, there or in transit
|
Posted: Sat Feb 10, 2007 5:56 pm Post subject: |
|
|
Sakkath wrote: | Maybe `confcat` should go in baselayout |
Or perhaps gentoolkit. I named mine ecat for Gentoo-ishness and as a nod to Ed Catmur. _________________ Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others. |
|
Back to top |
|
|
Sakkath Apprentice
Joined: 06 Nov 2005 Posts: 198 Location: Pawtucket, RI
|
Posted: Sat Feb 10, 2007 6:15 pm Post subject: |
|
|
timeBandit wrote: | Sakkath wrote: | Maybe `confcat` should go in baselayout |
Or perhaps gentoolkit. I named mine ecat for Gentoo-ishness and as a nod to Ed Catmur. |
Yeah that's a better idea . _________________ The person who makes no mistakes does not usually make anything.
Please add [SOLVED] to the subject of your original post when you feel that your problem is resolved. |
|
Back to top |
|
|
carpman Advocate
Joined: 20 Jun 2002 Posts: 2202 Location: London - UK
|
Posted: Mon Jun 11, 2007 10:28 am Post subject: |
|
|
cheers very helpful _________________ Work Station - 64bit
Gigabyte GA X48-DQ6 Core2duo E8400
8GB GSkill DDR2-1066
SATA Areca 1210 Raid
BFG OC2 8800 GTS 640mb
--------------------------------
Notebook
Samsung Q45 7100 4gb |
|
Back to top |
|
|
VinzC Watchman
Joined: 17 Apr 2004 Posts: 5098 Location: Dark side of the mood
|
Posted: Sun Oct 21, 2007 10:05 am Post subject: |
|
|
Late jumping in, I recon - I've just followed the link from UberLord's signature...
I've been using an alias for purging comments from files. I've put the alias definition in .bash_profile as follows:
.bash_profile: | alias purge="egrep -v '^[[:space:]]*#|^ *$|^$'" |
It takes less than a script and is more convenient, IMHO. For now it works only on shell files but if you want to strip off comments à la Samba, just append "|^[[:space:]]*;".
As a suggestion, just put it in /etc/skel/.bash_profile ? _________________ Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739! |
|
Back to top |
|
|
Phredus n00b
Joined: 07 Feb 2013 Posts: 47
|
Posted: Sun Jun 29, 2014 10:44 am Post subject: Thank you for the script |
|
|
I'm just starting to get deep into Gentoo, I love it!!!
Thank you |
|
Back to top |
|
|
|