commit 6092d42ba117d417206d50f00f85b7639d665d4d
parent 9d8e832ae98ad142e10ee43a258b7215893126d1
Author: St John Karp <contact@stjo.hn>
Date: Thu, 14 Oct 2021 05:16:11 -0400
Use `tail` to remove `ps` header instead of subtracting 1 from `wc`
I'm not sure if one approach is better than the other, but this
at least seems neater than nesting subshells.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/squeeze.sh b/squeeze.sh
@@ -95,7 +95,7 @@ find "$source_path" -type f -name "*.md" $find_test |
# or equal to the max processes. We have to subtract one
# because the `ps` command always outputs a header that we
# don't want to count.
- while [ "$(expr "$(ps -p "${proc_ids%% }" | wc -l | tr -d -c '[:digit:]')" - 1)" -ge "$max_processes" ] ; do
+ while [ "$(ps -p "${proc_ids%% }" | tail -n +2 | wc -l | tr -d -c '[:digit:]')" -ge "$max_processes" ] ; do
true
done
done