Better HN
topnewbestaskshowjobs
Log inSign up

m-manu

5 karma · joined Jul 21, 2014 (12y ago) · 7 submissions

https://github.com/m-manu

https://www.linkedin.com/in/manu-manjunath/

Submissions

comment 4mo ago · link · parent

grep is great. It comes pre-installed on your OS. In fact, a search using grep is faster than the search on your IDE when there is no code index!

But, one key pain when using grep for searching in your source code or configuration files? A `grep -r` command scans all files (including binary files ) and not just source code files, making it slow. Sometimes, terribly slow.

Yes, I'm aware of source-code-aware search tools like ripgrep (rg), ack etc. - But these tools reimplement grep logic!

Annoyed by this, a few years back, I wrote a grep wrapper that runs your systems grep on "source code files". I called it "scgrep" ("source code grep" for short).

It's written it in pure Go (zero library dependencies).

I have been using it ever since and it's been working great.

2.

Source Code Grep: Use your own grep, but make it source code aware(github.com ↗)

2 points · by m-manu · 4mo ago · 1 comment

comment 4y ago · link · parent

My homepage is on Github. Didn't know Cloudflare also provides free hosting. Thanks.

comment 5y ago · link · parent

The tool doesn't delete anything -- just reports. If you're uncomfortable with "fuzzy hash", use the -thorough cmd line option.

comment 5y ago · link · parent

Yes, you can run it on whole hard drive. If you're planning to use it on "low entropy" file formats like "header" files, then use -thorough option.

comment 5y ago · link · parent

Changes have been incorporated. FYI.

comment 5y ago · link · parent

As the author of the tool, thanks a lot for wonderful inputs! Many comments are actionable. I'll incorporate them in code soon.

Now to address a few concerns:

# The tool doesn't delete anything -- As the name suggests, it just finds duplicates. Check it out.

# File uniqueness is determined by file extension + file size + CRC32 of first 4KiB, middle 2KiB and last 2KiB

# Above seems not much. But, on my portable hard drive with >172K files (mix of video, audio, pics and source code), I got the same number of collisions as that of "SHA-256 of entire file" (By the way, I'm planning to add an option in the tool to do this)