-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathlines.sh
executable file
·42 lines (34 loc) · 926 Bytes
/
lines.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# Array of directories to scan
directories=(
"./program"
"./core"
"./integration_tests"
"./cli"
)
total=0
# Function to count lines in a directory
count_lines() {
local dir=$1
if [ ! -d "$dir" ]; then
echo "Warning: Directory $dir does not exist, skipping..."
echo 0
return
fi
local count=$(find "$dir" -name "*.rs" -type f -exec wc -l {} + | awk '{total += $1} END {print total}')
# If no Rust files found, count will be empty
if [ -z "$count" ]; then
count=0
fi
echo "$dir: $count lines"
echo $count
}
# Process each directory
for dir in "${directories[@]}"; do
count=$(count_lines "$dir")
# Get the last line of output (the count)
dir_count=$(echo "$count" | tail -n 1)
total=$((total + dir_count))
done
echo "----------------------------------------"
echo "Total lines of Rust code: $total"