I am on macOS and would like to get into using grep (or a similar tool) to find unique occurrences of a certain pattern in a codebase. For example, for finding all console.somemethod() calls in JavaScript I have devised:
grep -oiER "console\.([a-z]+)\(" . | sort -u
But this gets me results in the form:
./tools/svg-inject/node_modules/with/node_modules/acorn/src/bin/acorn.js:console.log(
./tools/svg-inject/node_modules/wordwrap/README.markdown:console.log(
./tools/svg-inject/node_modules/wordwrap/example/center.js:console.log(
./tools/svg-inject/node_modules/wordwrap/example/meat.js:console.log(
./tools/svg-inject/node_modules/yargs/README.md:console.dir(
./tools/svg-inject/node_modules/yargs/README.md:console.log(
./tools/svg-inject/node_modules/yargs/index.js:console.log(
./tools/svg-inject/node_modules/yargs/lib/usage.js:console.error(
./tools/svg-inject/node_modules/yargs/lib/usage.js:console.log(
./webpack.config.js:console.info(
Console.sendTo(
console.error(
console.log(
console.markTimeline(
console.reactStackEnd(
console.timeEnd(
console.trace(
console.warn(
I would like to restrict it to unique matches of the ([a-z]+) group only:
info
sendTo
error
log
markTimeline
reactStackEnd
timeEnd
trace
warn
Apologies if I'm rehashing an old question!