-
Notifications
You must be signed in to change notification settings - Fork 9
/
lines.sh
40 lines (40 loc) · 1.48 KB
/
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
#!/bin/bash
#this example prints line count for all found files
total=0
find Source/ -type f -name "CMakeSources.cmake" -o -name "CMakeLists.txt" | while read FILE; do
#you see use grep instead wc ! for properly counting
count=$(grep -c ^ < "$FILE")
echo "$FILE has $count lines"
let total=total+count #in bash, you can convert this for another shell
echo "$total"
echo "$total" > cmake.txt
done
find Source/CMake -type f -name "*.cmake" | while read FILE; do
#you see use grep instead wc ! for properly counting
count=$(grep -c ^ < "$FILE")
echo "$FILE has $count lines"
let total=total+count #in bash, you can convert this for another shell
echo "$total"
echo "$total" > cmake_conf.txt
done
total=0
find Data/ -type f -name "*.hlsl" -o -name "*.txt" -o -name "*.cpp" | while read FILE; do
#you see use grep instead wc ! for properly counting
count=$(grep -c ^ < "$FILE")
echo "$FILE has $count lines"
let total=total+count #in bash, you can convert this for another shell
echo "$total"
echo "$total" > other.txt
done
total=0
find Source/ -type f -name "*.cpp" -o -name "*.h" | while read FILE; do
#you see use grep instead wc ! for properly counting
count=$(grep -c ^ < "$FILE")
echo "$FILE has $count lines"
if (echo "$FILE" | egrep "(.*)\/Te([a-zA-Z0-9]+)\.(.*)"); then
let total=total+count #in bash, you can convert this for another shell
echo "$total"
echo "$total" > code.txt
fi
done
read touche