Re: [PATCH 1/5] Makefile: use grep -c to avoid wc -l

Michael Ellerman <[email protected]> Tue, 07 Feb 2017 21:05:45 +1100
Newsgroups org.kernel.vger.trinity
Message-ID <[email protected]>
Tommi Rantala <[email protected]> writes:

> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index b93fc3a..16fafe8 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2,7 +2,7 @@ VERSION="1.8pre"
>  
>  INSTALL_PREFIX ?= $(DESTDIR)
>  INSTALL_PREFIX ?= $(HOME)
> -NR_CPUS := $(shell grep ^processor /proc/cpuinfo | /usr/bin/wc -l)
> +NR_CPUS := $(shell grep -c ^processor /proc/cpuinfo)

Or you could just use nproc(1) ?

It's in coreutils, but maybe that's not sufficiently portable?

cheers