Hi, On Sun, 14 Jan 2018 22:18:26 +0200 Vasyl Vavrychuk <vvavryc...@gmail.com> wrote:
> Hi, John, > > On Sun, Jan 14, 2018 at 8:48 AM, john doe <johndoe65...@mail.com> wrote: > > On 1/14/2018 7:28 AM, john doe wrote: > > > > $ dpkg-query -W -f='${db:Status-Abbrev}${binary:Package}\n' awk git > > gawk cmake 2>&1 | awk '!/^ii/ || !/^un/{print $6}' > > git > > gawk > > cmake > > I also tried to parse stderr, but then I realized that relying on the > output > > dpkg-query: no packages found matching > > is not correct since it might be localized and is not suitable for > scripting. if you need the English output messages you can get these simply with LC_ALL=C dpkg-query ... Maybe you could alternatively use the apt list command (however it should be noted that the developers still say the apt command should be used only with care in scripts (see man apt)). The output of apt list here looks like: $ LC_ALL=C apt list gawk git cmake konsole foobar 2> /dev/null | grep installed cmake/stable,now 3.7.2-1 amd64 [installed] gawk/stable,now 1:4.1.4+dfsg-1 amd64 [installed] git/stable,stable,now 1:2.11.0-3+deb9u2 amd64 [installed] $ LC_ALL=C apt list gawk git cmake konsole foobar 2> /dev/null | grep -v installed Listing... konsole/stable 4:16.12.0-4 amd64 The non-existing "foobar" package simply appears in neither of these commands' output. Not sure what exactly you want to achieve, maybe this might be a way to go. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. You're too beautiful to ignore. Too much woman. -- Kirk to Yeoman Rand, "The Enemy Within", stardate unknown