Have you ever been interested how many files your application consists of? Or how many lines have you and your developers have written in this app? Here is how to easily count them.
find, cat
and wc
commands used below are installed on OS X and Linux by default.Although the ports to Windows do exist, I have not tested them because I do not have a Windows computer with Ext project. Hence, I welcome comments from Windows users very much.
Calculate number of files
cd /your/project/dir find -E app.js app ux overrides sass packages/mytheme \ -regex '.*\.(js|scss)' | wc -l
This command descend to app, ux, overrides, sass
and packages/mytheme
directories to find JavaScript
and Sass
files.
If you have your sources in some additional directories just add them to the list, or remove theme directory from the list if you don’t use a custom theme. Similarly, if you want to count, for example, PHP
files, add them to the list of extensions in the regex expression: -regex '.*\.(js|scss|php)'
The file names are then piped (|) to wc
command – which, by the way, stands for “word count”, not for “water closet” – that with -l
switch counts lines, in this case files.
The output is a single number giving you the number of files matching the find conditions. In one of the projects I’ve supervised recently it was 1047.
Calculate number of lines
It is very similar, we only need to concatenate the content of files before we pipe it to wc
command. Thus:
cd /your/project/dir find -E app.js app ux overrides sass packages/mytheme \ -regex '.*\.(js|scss)' -exec cat {} \; | wc -l
Again, output is a single integer. In my case it was 146,206.
Feel free to post your results in comments.
- Ext, Angular, React, and Vue - 27. June 2019
- The Site Resurgence - 11. February 2018
- Configuring ViewModel Hierarchy - 19. June 2015
One Response
I see your website needs some unique & fresh articles.
Writing manually is time consuming, there is tool for this task.
Just search in gogle for: Fejlando’s tips