![]() ![]() I have to specify a recursive search on the current directory (the -recursive option, plus the trailing dot). Though it doesn’t show in this output, the results include only files containing schema and not Schema or SCHEMA. The results don’t include some of the files I was most interested in because the defaults assume a case-sensitive search, which I don’t want. In fact, they’re excluded from my repository with a. I don’t care about those files because they’re not my project files. The results include lots of non-project files from my dependencies, which are the lines starting with node_modules. There are a few problems with this search: worktrees/meta/node_modules/ajv/README.md worktrees/meta/node_modules/eslint/CHANGELOG.md worktrees/meta/node_modules/json-schema-traverse/README.md worktrees/meta/node_modules/js-yaml/README.md worktrees/meta/node_modules/js-yaml/CHANGELOG.md node_modules/json-schema-traverse/README.md node_modules/better-ajv-errors/README.md # In practice, I’d probably use the shorter, more cryptic form: $ grep -lR -include = '*.md' 'schema'. # For clarity, I’ve used the long form for all options in this article. $ grep -recursive -files-with-matches 'schema' -include = '*.md'. Historically, I might’ve started with something like this: To demonstrate, I’m going to search a project I contribute to a lot, mdn/browser-compat-data, for the string schema. Here’s an example: suppose I want to get a list of all the Markdown files in a repository containing a specific word. The failures of a traditional code search In particular, I’m a fan of ripgrep, but each offers a similar set of benefits over the traditional tools. ![]()
0 Comments
Leave a Reply. |