I was looking for strings in this format
calc_name=RegularIRA calc_name=Savings
Here is the solution:
grep -oh "calc_name=\w*" * | sort | uniq -c > calculator_counts.txt
This searches all files in the current directory for the pattern "calc_name=\w*" (which stops as soon as a non word character (like a symbol) is found. Then it sorts them, and runs the "uniq" command to get a count of unique occurrences. Then the output is piped to a file.
The output looks like this:
1332 Annuity 59 AssetAllocator 4411 AutoEquityLoan 119 AutoLoan 4 AutoPayoff 333 AutoRebate
I should also note, if you want to use Perl-compatible regular expressions, add the "-P" flag to the "grep" command, like so:
ReplyDeletegrep -Poh "calc_name=[\w.]*"
That is why you were johnny on the spot with the suggestion earlier... :)
ReplyDelete