-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprofile-bash-5
executable file
·42 lines (36 loc) · 960 Bytes
/
profile-bash-5
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
#!/usr/bin/env bash
start=""
before=""
lineCount=0
while read -r line; do
if [[ "$line" == "+"* ]]; then
now=${line#* }
now=${now%% *}
now=${now/.}
if [[ -z "$start" ]]; then
start=$now
before=$now
fi
elapsed=$((now - before))
total=$((now - start))
elapsed="00000$elapsed"
elapsed="${elapsed:0:-6}.${elapsed: -6}"
elapsed=${elapsed#0}
elapsed=${elapsed#0}
elapsed=${elapsed#0}
elapsed=${elapsed#0}
elapsed=${elapsed#0}
elapsed=${elapsed/#./0.}
total="00000$total"
total="${total:0:-6}.${total: -6}"
total=${total#0}
total=${total#0}
total=${total#0}
total=${total#0}
total=${total#0}
total=${total/#./0.}
lineCount=$((lineCount + 1))
echo "$total $elapsed $lineCount ${line%% *} ${line#* * }"
before=$now
fi
done