Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-19-2004, 12:25 AM   #1
Senior Member
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 45
looking for script - strip out all # comments

Hey, you scripters....

Anybody got a simple script I can use, sorta like:

$ strip_comments /etc/rc.d/rc.modules

and have the output just show all lines that don't have # in the first column?
This is no emergency or anything.

Thanks if you do and can post it...

I just haven't gotten around to writing any scripts yet.
Old 02-19-2004, 03:36 AM   #2
Registered: Jun 2001
Location: Houston, TX, USA
Distribution: Debian
Posts: 569

Rep: Reputation: 31
grep -v "^#"

Pipe anything you want to that
Old 02-21-2004, 06:23 PM   #3
Senior Member
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Original Poster
Rep: Reputation: 45

Exactly what I as looking for.

Old 03-11-2004, 11:57 AM   #4
Senior Member
Registered: Mar 2004
Location: england
Distribution: Debian, Mint, Puppy, Raspbian
Posts: 3,421

Rep: Reputation: 200Reputation: 200Reputation: 200
If the comment is NOT the first character,
Like # here for instance

cat file | sed 's/#.*//' | grep .



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
strip -s blackzone Linux - Newbie 1 09-01-2004 01:08 AM
strip command? blackzone Linux - General 2 07-09-2004 04:20 AM
How to remove or strip control chars in the 'script' utility? fieldmethods Linux - General 1 10-24-2003 02:11 PM
How sed strip /* comments aaronzh Programming 1 06-05-2003 06:16 PM
Program (or Script) to download Slashdot Article with Comments LinuxGeek Linux - General 1 08-24-2002 04:29 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:58 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration