Download your favorite Linux distribution at LQ ISO.
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 06-04-2003, 10:34 PM   #1
LQ Newbie
Registered: Jun 2003
Posts: 1

Rep: Reputation: 0
Question How sed strip /* comments

how to strip c comments using sed?
/* #include is commented */
This is a line in file.txt. I want to change it to
#include is uncommented in the file.
I am thinking of using
sed 's/\/* #include is commented *\//#include is uncommented/g' file.txt > file_new.txt
But it won't work. Who can shed some lights here.
Old 06-05-2003, 06:16 PM   #2
Registered: May 2003
Location: Nashville TN, USA
Distribution: Debian (I'm unstable)
Posts: 117

Rep: Reputation: 15
you need to escape the * too (it represents 0 or more of something)
sed "s/\/\*#include is commented\*\//#include is uncommented/"


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
Why strip binaries? rsamurti Slackware 4 06-27-2004 05:17 PM
looking for script - strip out all # comments itsjustme Programming 3 03-11-2004 11:57 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 07:12 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:25 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