Stack Exchange
grep exit with status 1 when found zero value
below is my code
1_week=$(git log --since=$(date +"%Y-%m-%d" --date="@$(($(date +%s) - 604800))")|grep '^commit ' |wc -l) && 2_week=$(git log --since=$(date +"%Y-%m-%d" --date="@$(($(date +%s) - 604800))")|grep '^Author:' |sort -u|wc -l)

error:
+ let '1_last_week += 0'
/home/mytestshell.sh exited with return code 1

and I tried below referring this https://blog.m157q.tw/posts/2021/06/09/be-careful-when-using-grep-on-circleci/
1_week=$(git log --since=$(date +"%Y-%m-%d" --date="@$(($(date +%s) - 604800))")|grep '^commit ' || true |wc -l) && 2_week=$(git log --since=$(date +"%Y-%m-%d" --date="@$(($(date +%s) - 604800))")|grep '^Author:' || true |sort -u|wc -l)

but it still gives exit 1 error if found value is zero, can someone guide what I am missing here
Regards,

The error message mentions let, 1_last_week and +=, neither of which are in the code you show. What does /home/mytestshell.sh contain? Besides, variable names can't start with a digit.

I get bash: let: 1_last_week: value too great for base (error token is "1_last_week") for that let command. Take care to post your full script and any errors you get, it helps people help you if they don't have guess about something you didn't show.

You don't say which shell this is being written for, but generally variable names can't start with a digit.
I would strongly recommend that you start to paste your code into https://shellcheck.net (or install shellcheck locally). It will help pick up a lot of issues that you can then address directly.
Your style would benefit from improvement too. A long line of intense code isn't easy to read and understand. As a contrast here is an alternative style
#!/bin/sh
#
dt_since=$(date --date='1 week ago' +'%Y-%m-%d')

nr_commits=$(git log --since="$dt_since" | grep '^commit ' | wc -l)
nr_authors=$(git log --since="$dt_since" | grep '^Author:' | sort -u| wc -l)

You can then then perform some maths with the results in $nr_commits and $nr_authors. I'm not sure what it is you're trying to achieve so I've interpreted your && as meaning you want a success (0 value) exit status if there is at least one commit from one author:
[ $nr_commits -gt 0 ] && [ $nr_authors -gt 0 ]
exit

(Note that if $nr_commits is non-zero then there must have been an author, so you could optimise the expression by removing the check on $nr_authors entirely.)
Regarding the error with let, there isn't any let in the code you have shown us so we cannot help with that.
