Skip to content

Commit da29d34

Browse files
committed
Fix grep RegExp
1 parent 01b45fa commit da29d34

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

tools/git/scripts/commits_per_day

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
# * `git log --reverse`
88
# - Show commit logs in reverse order.
9-
# * `grep Date`
9+
# * `grep '^Date'`
1010
# - Extract the line which begins with `Date` from each log.
1111
# * `awk '{}'
1212
# - From each date line, extract the month (`$3`), day (`$4`), and year (`$6`).
1313
# * `uniq -c`
1414
# - Given that same day commits are on consecutive lines, we can remove repeated lines and count the repeats to show daily totals.
1515
# * `awk '{}'`
1616
# - Format the output.
17-
git log --reverse | grep Date | awk '{print $6 OFS $3 OFS $4}' | uniq -c | awk '{print $3 OFS $4 OFS $2 OFS $1}'
17+
git log --reverse | grep '^Date' | awk '{print $6 OFS $3 OFS $4}' | uniq -c | awk '{print $3 OFS $4 OFS $2 OFS $1}'

tools/git/scripts/commits_per_hour

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# * `git log`
88
# - Show commit logs.
9-
# * `grep Date`
9+
# * `grep '^Date'`
1010
# - Extract the line which begins with `Date` from each log.
1111
# * `awk '{}'`
1212
# - From each date line, extract the hour.
@@ -16,7 +16,7 @@
1616
# - Remove repeated lines and count the repeats to show hourly totals.
1717
# * `awk '{}'`
1818
# - Format the output.
19-
git log | grep Date | awk '
19+
git log | grep '^Date' | awk '
2020
{
2121
split($5, time, ":")
2222
print time[1]

tools/git/scripts/commits_per_month

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# * `git log`
88
# - Show commit logs.
9-
# * `grep Date`
9+
# * `grep '^Date'`
1010
# - Extract the line which begins with `Date` from each log.
1111
# * `awk '{}'`
1212
# - From each date line, extract the month (`$3`) and year (`$6`).
@@ -16,4 +16,4 @@
1616
# - Remove repeated lines and count the repeats to show monthly totals.
1717
# * `awk '{}'`
1818
# - Format the output.
19-
git log | grep Date | awk '{print $6 OFS $3}' | sort -k1n -k2M | uniq -c | awk '{print $3 OFS $2 OFS $1}'
19+
git log | grep '^Date' | awk '{print $6 OFS $3}' | sort -k1n -k2M | uniq -c | awk '{print $3 OFS $2 OFS $1}'

tools/git/scripts/commits_per_weekday

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# * `git log`
88
# - Show commit logs.
9-
# * `grep Date`
9+
# * `grep '^Date'`
1010
# - Extract the line which begins with `Date` from each log.
1111
# * `awk '{}'`
1212
# - From each date line, extract the weekday (`$2`).
@@ -16,7 +16,7 @@
1616
# - Remove repeated lines and count the repeats to show weekday totals.
1717
# * `awk '{}'`
1818
# - Sort the weekdays from Monday to Sunday.
19-
git log | grep Date | awk '{print $2}' | sort | uniq -c | awk '
19+
git log | grep '^Date' | awk '{print $2}' | sort | uniq -c | awk '
2020
BEGIN {
2121
split("Mon Tue Wed Thu Fri Sat Sun", days);
2222
}

tools/git/scripts/commits_per_year

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
# * `git log`
88
# - Show commit logs.
9-
# * `grep Date`
9+
# * `grep '^Date'`
1010
# - Extract the line which begins with `Date` from each log
1111
# * `awk '{}'`
1212
# - From each date line, extract the year (`$6`).
1313
# * `sort -r`
1414
# - Sort in reverse lexicographic order.
1515
# * `uniq -c`
1616
# - Remove repeated lines and count the repeats to compute yearly totals.
17-
git log | grep Date | awk '{print $6}' | sort -r | uniq -c | awk '{print $2 OFS $1}'
17+
git log | grep '^Date' | awk '{print $6}' | sort -r | uniq -c | awk '{print $2 OFS $1}'

0 commit comments

Comments
 (0)