Results 1 to 7 of 7
Is there a way to use the grep command in conjunction with an editor such as nano or vi so that I can remove the commented out lines from a ...
- 02-16-2011 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 53
grep command and then edit how ?
Is there a way to use the grep command in conjunction with an editor such as nano or vi so that I can remove the commented out lines from a conf file and then proceed to edit it ?
I can use grep -v "^#^" squid.conf (example ) which gives me a nicely tidy conf file but I can't edit it.
Can this command be used with nano or ??
-keevill-
- 02-16-2011 #2Just Joined!
- Join Date
- Feb 2011
- Location
- Oregon, USA
- Posts
- 6
Hmm, interesting idea. Never thought of that. Curious to see if anyone knows how to do this.
- 02-18-2011 #3
interesting, indeed.
If you really don't want the the comments you may replace the conf file with the grep output. Then edit it. (your command as an extra ^)
# cp squid.conf squid.conf.bak
# grep -v "^#" squid.conf > squid.conf
# nano squid.conf
I think you cant expect to edit without (without seeing?) the comments and save it back with the comments, right? Then again, what do I know?
Regards
Luis
- 02-18-2011 #4Code:
sed -i /^#/d squid.conf
You must always face the curtain with a bow.
- 02-20-2011 #5Just Joined!
- Join Date
- Oct 2009
- Posts
- 53
- 02-20-2011 #6
sed is a stream editor.
The idea is, that it is *not* interactive, ie: no gui will be shown. In fact: sed has none.
It reacts to commands and regular expressions.
sed -i /^#/d squid.conf
sed is called to work on a file squid.conf.
/^#/ match lines, that begin with a #
and delete them /d
-i work in-place. That means: modify squid.conf instead of just printing the output to stdout.You must always face the curtain with a bow.
- 02-20-2011 #7Just Joined!
- Join Date
- Oct 2009
- Posts
- 53


Reply With Quote
