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

  • Home
  • SEARCH
  • 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 6727883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:06:11+00:00 2026-05-26T10:06:11+00:00

I have to maintain a large old project project where my forerunners (for lack

  • 0

I have to maintain a large old project project where my forerunners (for lack of version control) have turned large portions of code into comments.
Now that we have everything in version control, I feel we no longer need these comments.
The code in those comments has rotten anyway.

I would like to find the longest of those comments. It would be nice to have a way that gives me all files that have, let’s say, more than 20 consecutive comment lines.
As far as I can tell only // has been used. Finding /* */ is not necessary (probably even harmful because it’d find all the rotten javadoc… sigh).

  • 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-05-26T10:06:12+00:00Added an answer on May 26, 2026 at 10:06 am

    Howabout this:

    grep -ERn '^[[:space:]]*//' root_directory
    

    The -E uses ‘extended’ regexes

    The -R makes it recurse directories

    The -n prints the filnames with line numbers

    Then you can easily process this list to look for consecutive matches – just look for a block where the line number increases by one per line of output.

    This assumes you don’t want to match lines like this:

    int x = foo; // some comment
    

    But only lines that are completely comments:

    // this is a comment
    

    Update:

    Here’s a short Python script to process the output of the above grep:

    import sys
    
    filenames_of_interest = set()
    filename = None
    prev_line_num = 0
    comment_count = 0
    for line in sys.stdin.readlines():
            this_filename, line_num, _ = line.split(':',2)
            line_num = int(line_num)
            if this_filename != filename:
                    comment_count = 0
                    filename = this_filename
            elif line_num != prev_line_num + 1:
                    comment_count = 0
            prev_line_num = line_num
            comment_count += 1
            if comment_count > 20:
                    filenames_of_interest.add(filename)
    
    print "files with blocks of comments:"
    for i in filenames_of_interest:
            print ' ', i
    

    It won’t treat files with colons in their name correctly, but shouldn’t be hard to modify to deal with that if it’s an issue.

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

Sidebar

Related Questions

In a recent project, I have to maintain some PHP code. I set up
I have to maintain a large number of classic ASP pages, many of which
I have a large classic ASP app that I have to maintain, and I
I have to maintain an old VB 6 ActiveX DLL called by another third-party
I have an old Delphi codebase I have to maintain, lots of DLLs, some
I am preparing an Excel sheet in which I have to maintain the version
I have a vector containing large number of elements. Now I want to write
Background: I have a project that is not at all large scale (2 ASP.NET
Over time, the code base I maintain has grown exponentially. We have a variety
I have inherited a large existing website to maintain. Previous developers have taken an

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.