Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
For some reason, I'm pulling a brainfart on this...it's something I've done a few times, but now I can't remember how *sigh*, getting old can sometimes suck.
Ok, because, for the life of me, I can't remember how to do this in vi, here's a quick kludge. Assuming that, like most shells scripts, comments start out with a # as the first thing on the line, you can do this.
cat some_file | grep -v ^# > some_new_file
If someone can kickstart my brain and post the vi equivalent for this, I'd appreciate it.
Last edited by Technoslave; 05-07-2004 at 02:42 AM.
Originally posted by mikshaw But at the same time you're removing the first line, which is an important part of the script.
thanks, good call.. i'd forgotten about the shebang, since i was trying this out on /etc/squid/squid.conf, which uses "#" for comments also but isn't a shell script, hence no shebang...
okay i think i found a way to remove the blank lines...
this (example) would make it so that there is no more than one blank line at a time (".stripped" means the comments have already been removed using cat and grep):
and it seems this would get rid of the blank lines entirely (i googled a bit and found this here):
cat -s /etc/squid/squid.conf.stripped | sed '/^[[:space:]]*$/d' > /etc/squid/squid.conf.stripped.noblanks
do you know of a simpler way to do it, or is this pretty much it??
i'm wondering if "sed" is supposed to be a "standard" part of GNU (as i believe cat and grep to be), so as one could expect every distro to have sed...???
sorry for being such a newbie...
thanks so much for your input, i really appreciate it...
tr (short for translate) is just a filter. It's a filter in the truest sense of the word. It just filters it's input and writes it to stdout. What you want is probably something like:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.