I wanted to know how many files that ended in either .test.ts or .test.js in a directory, came up with this guy:
tree --noreport --gitignore -i | grep -c -E '\.test\.(js|ts)'
Tree
tree is a tool for listing out the contents of a directory in a tree-style format.
--noreportRemoves a summary line at the bottom ("10 directories, 35 files")--gitignoreLooks for a.gitignorefile and excludes those directories, useful for those peskynode_modulesdirectories-iRemoves the whitespace and indent (makes it better input for regex)
Grep
Grep is a tool for searching text against a regex.
We pass in the input from tree into Regex, and only look for files that match a pattern
-cfor "count", i.e. just tell me how many matches you found-Efor extended regex, it makes the(js|ts)fragment work