cupid-lc is a line count utility written in C for Unix and Linux systems. It calculates the total number of lines across files in a given directory or for a single file. The output includes both a cumulative total and individual line counts for each file processed.
- Counts the total lines in a directory (including subdirectories) or a single file.
- Provides a line count for each file and a cumulative total.
- Recursive directory traversal for in-depth counting.
- Simple command-line interface, easy to integrate into scripts or workflows.
To use cupid-lc
, simply pass a file or directory as an argument.
# Count lines in a directory
./cupid-lc src/
# Sample output:
# cupid-lc: line count per src/main.c : 73
# cupid-lc: line count total: 73
Or pass a single file:
./cupid-lc test.txt
# Sample output:
# cupid-lc: line count per test.txt: 3
# cupid-lc: line count total: 3
To compile the program, clone the repository and use gcc
to build the executable.
git clone https://github.com/username/cupid-lc.git
cd cupid-lc
gcc src/main.c -o cupid-lc
When you're done building, I suggest moving the executable to the /usr/bin/
directory for system-wide use in the terminal.
Replace username
with your GitHub username.
Run the compiled cupid-lc
with the directory or file path as an argument:
./cupid-lc [directory_or_file]
[directory_or_file]
: The path to a directory or a file for which to calculate line counts.
The program will print the line count for each file, followed by a total line count. The format is as follows:
cupid-lc: line count per <filename>: <line_count>
cupid-lc: line count total: <total_line_count>
For a directory containing multiple files:
cupid-lc: line count per src/main.c : 301
cupid-lc: line count per src/count.c: 2000
cupid-lc: line count total: 2301
For a single file:
cupid-lc: line count per test.txt: 42
cupid-lc: line count total: 42
This project is licensed under the GNU v3 License - see the LICENSE file for details.