I want to see how many packages from a list are not installed. I use archlinux, so I use pacman -Q to determine if a package is installed. If it is not installed, it returns a message like: error: package 'package-name' was not found.I thought I could use grep -c 'error' like this:pacman -Q autoconf automake binutils bison fakeroot flex gcc libtool m4 make patch pkg-config | grep -c 'error'But for me it returns:error: package 'bison' was not found  error: package 'pkg-config' was not found  0It returns 0, but I would like it to return 2. Even with awk it doesn't work:pacman -Q autoconf automake binutils bison fakeroot flex gcc libtool m4 make patch pkg-config | awk '/error: / {count++} END {print count}'For me, this returns:error: package 'bison' was not found  error: package 'pkg-config' was not found  So my guess is that variable count doesn't even have a value since it doesn't get printed. I also tried wc -l, but that doesn't work, it just returns 0 for me.What is the correct way to print the number of not-installed packages?EDIT: I noticed when I do:pacman -Q autoconf automake binutils bison fakeroot flex gcc libtool m4 make patch pkg-config > tempfile  cat tempfileThe two rows containing the error message are not added to tempfile (the rest of the command output does). Thought this might help solving this problem.
Finding out how many programs I have not installed from a list with grep/awk in archlinux
linux;grep;awk;pacman
The problem is the error messages are not send to STDOUT but STDERR. You have to explicitly redirect STDERR as well, e.g:pacman -Q bison patch pkg-config 2>&1 | grep -c 'error'If you have something like bash or zsh you can use |& to automatically redirect STDOUT as well as STDERR:pacman -Q bison patch pkg-config |& grep -c 'error'