The scc (Sloc Cloc and Code) is a command line tool used for counting lines of code (LOC) in a project. It's similar to other tools like cloc
and tokei
, but it comes with a few additional features and optimizations, making it particularly fast and efficient for analyzing large codebases. This tutorial shows how to install scc source code line counter on Ubuntu 24.04.
Install scc
Run the following command to download the tar.gz
file from the releases page of the scc repository:
wget -qO scc.tar.gz https://github.com/boyter/scc/releases/latest/download/scc_Linux_x86_64.tar.gz
Extract executable from tar.gz
file to /usr/local/bin
directory:
sudo tar xf scc.tar.gz -C /usr/local/bin scc
We can check scc version as follows:
scc --version
Remove unnecessary tar.gz
file:
rm -rf scc.tar.gz
Testing scc
Create a main.c
file for testing:
nano main.c
Add the following code:
#include <stdio.h>
// Hello world program
int main() {
printf("Hello world\n");
return 0;
}
Execute the scc
command to count the lines of code:
scc main.c
The command will display the following results:
───────────────────────────────────────────────────────────────────────────────
Language Files Lines Blanks Comments Code Complexity
───────────────────────────────────────────────────────────────────────────────
C 1 8 2 1 5 0
───────────────────────────────────────────────────────────────────────────────
Total 1 8 2 1 5 0
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop (organic) $103
Estimated Schedule Effort (organic) 0.42 months
Estimated People Required (organic) 0.02
───────────────────────────────────────────────────────────────────────────────
Processed 102 bytes, 0.000 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────
You can provide a directory as an argument to the scc
command. It will analyze the specified directory and all its subdirectories. For instance, download the scc source code from GitHub:
wget -qO scc-master.tar.gz https://github.com/boyter/scc/archive/master.tar.gz
tar xf scc-master.tar.gz
Execute the scc
command to analyze the specified directory:
scc scc-master
Uninstall scc
If you no longer need scc, you can delete the executable:
sudo rm -rf /usr/local/bin/scc
Leave a Comment
Cancel reply