vagrant@debian-607-x64-vbox4210:~$ dpkg -s tree && ! dpkg -s tree | grep -E "^Status: .+ not-installed$"
Package `tree' is not installed and no info is available.
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
vagrant@debian-607-x64-vbox4210:~$ echo $?
1
vagrant@debian-607-x64-vbox4210:~$ sudo apt-get install tree
vagrant@debian-607-x64-vbox4210:~$ dpkg -s tree && ! dpkg -s tree | grep -E "^Status: .+ not-installed$"
Package: tree
Status: install ok installed
Priority: optional
Section: utils
Installed-Size: 96
Maintainer: Florian Ernst <florian@debian.org>
Architecture: amd64
Version: 1.5.3-1
Depends: libc6 (>= 2.3)
Description: displays directory tree, in color
Displays an indented directory tree, using the same color assignments as
ls, via the LS_COLORS environment variable.
Homepage: http://mama.indstate.edu/users/ice/tree/
vagrant@debian-607-x64-vbox4210:~$ echo $?
0
vagrant@debian-607-x64-vbox4210:~$ sudo apt-get purge tree
vagrant@debian-607-x64-vbox4210:~$ dpkg -s tree && ! dpkg -s tree | grep -E "^Status: .+ not-installed$"
Package: tree
Status: unknown ok not-installed
Priority: optional
Section: utils
Status: unknown ok not-installed
vagrant@debian-607-x64-vbox4210:~$ echo $?
1
vagrant@precise64:~$ dpkg -s tree && ! dpkg -s tree | grep -E "^Status: .+ not-installed$"
Package `tree' is not installed and no info is available.
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
vagrant@precise64:~$ echo $?
1
vagrant@precise64:~$ sudo apt-get install tree
vagrant@precise64:~$ dpkg -s tree && ! dpkg -s tree | grep -E "^Status: .+ not-installed$"
Package: tree
Status: install ok installed
Priority: optional
Section: utils
Installed-Size: 100
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Version: 1.5.3-2
Depends: libc6 (>= 2.4)
Description: displays directory tree, in color
Displays an indented directory tree, using the same color assignments as
ls, via the LS_COLORS environment variable.
Original-Maintainer: Florian Ernst <florian@debian.org>
Homepage: http://mama.indstate.edu/users/ice/tree/
vagrant@precise64:~$ echo $?
0
vagrant@precise64:~$ sudo apt-get purge tree
vagrant@precise64:~$ dpkg -s tree && ! dpkg -s tree | grep -E "^Status: .+ not-installed$"
Package `tree' is not installed and no info is available.
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
vagrant@precise64:~$ echo $?
1