Search code examples
linuxbashlines-of-code

Using Bash to Count Lines of Code That I Have Written


I know that this script: find . -name '*' | xargs wc -l will count all the lines of code recursively in a directory, however since I am using plugins, the script will count those too.

I just want to be able to count the lines of code that I have written. If I add a commented string to each file that I write, how will I modify that script so it only counts files containing that specific string (perhaps something like originalCode-01-NoPlugin-).

Thanks in advance.


Solution

  • grep -rl 'originalCode-01-NoPlugin-' ./ | xargs wc -l does the trick, thanks for pointing me in the right direction @devnull

    It first finds the files and then counts the lines of code.