-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.sh
More file actions
32 lines (27 loc) · 692 Bytes
/
bench.sh
File metadata and controls
32 lines (27 loc) · 692 Bytes
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
#!/bin/bash
# Function to count lines in a file
count_lines() {
local file="$1"
local lines=$(wc -l < "$file")
echo "File: $file "
echo "Lines: $lines"
echo ""
}
# Recursive function to process files
process_files() {
local dir="$1"
# Loop through files in the directory
for file in "$dir"/*; do
if [[ -f "$file" ]]; then
if [[ "$file" == *.txt ]]; then
count_lines "$file"
fi
elif [[ -d "$file" ]]; then
process_files "$file"
fi
done
}
# Get the current working directory
cwd=$(pwd)
# Call the recursive function starting from the current directory
process_files "$cwd"