Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:10:59+00:00 2026-06-13T12:10:59+00:00

How do I remove all comments if they start with /* and end with

  • 0

How do I remove all comments if they start with /* and end with */
I have tried the following. It works for one line comment.

sed '/\/\*/d' 

But it does not remove multiline comments. for e.g. the second and third lines are not removed.

/*!50500 PARTITION BY RANGE (TO_SECONDS(date_time ))
 PARTITION 20120102parti VALUES LESS THAN (63492681600),
(PARTITION 20120101parti VALUES LESS THAN (63492595200) */ ;

In the above example, I need to retain the last ; after the closing comment sign.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:10:59+00:00Added an answer on June 13, 2026 at 12:10 pm

    If this is in a C file then you MUST use a C preprocessor for this in combination with other tools to temporarily disable specific preprocessor functionality like expanding #defines or #includes, all other approaches will fail in edge cases. This will work for all cases:

    [ $# -eq 2 ] && arg="$1" || arg=""
    eval file="\$$#"
    sed 's/a/aA/g; s/__/aB/g; s/#/aC/g' "$file" |
              gcc -P -E $arg - |
              sed 's/aC/#/g; s/aB/__/g; s/aA/a/g'
    

    Put it in a shell script and call it with the name of the file you want parsed, optionally prefixed by a flag like “-ansi” to specify the C standard to apply.

    See https://stackoverflow.com/a/35708616/1745001 for details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a macro in the Visual Studio editor to remove all comments from
Is there anyway or any addin for VS2010 that can remove all the comments
One can remove all calls to printf() using #define printf . What if I
I have the following HTML structure, (This cannot change). <!-- Comment 1 --> <div
I have read through all the threads out there that looked as if they
I am looking for a command-line tool that removes all comments from an input
I would like to remove all trailing zeros without truncating or rounding the number
I want to modify (Remove all white spaces) all the values of Column Name
I would like to remove all lines from a textfile which contain a certain
I need to remove all classes of 'no-right-marg' on all #tips li elements. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.