Calculate LOC by shell script

  • Navigating to you project folder, run(python project)
find . -name "*.py" |xargs grep -v "^$"|wc -l
  • If it is a Objective-C project, the the script should look like this:
find . -name "*.m" -or -name "*.h" |xargs grep -v "^$"|wc -l
  • If it is a Swift project, the the script should look like this:
find . -name "*.swift" |xargs grep -v "^$"|wc -l
grep -v “^$”: ignore blank lines
Like what you read? Give Zhihui Tang a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.