which installed debian packages depend on a debian package

Which installed debian packages depend on a debian package?

It must be a lazier way doing this.

I was not able to find that lazier way while searching the interwebz for over five minutes and it took me 10 minutes to write the following script and this post.

whatdependsonfrominstalled.sh
#!/bin/bash
#g0 2013 http://alog.ipduh.com/2013/08/which-installed-debian-packages-depend.html
## whatdependsonfrominstalled.sh: find out which installed debian packages depend on the passed debian package
## whatdependsonfrominstalled.sh: usage:: whatdependsonfrominstalled.sh debian-package-name :::eg::: whatdependsonfrominstalled.sh libc6

ME="whatdependsonfrominstalled.sh"
MEAT="/usr/bin/${ME}"

if [ -z $1 ]; then
 egrep '^##' ${MEAT}
 exit 3
fi

for i in `dpkg -l |egrep "^ii" |cut -f3 -d' '`;do 
 
 apt-cache depends ${i} |grep Depends: |grep ${1} > /dev/null
 if [ $? -eq 0 ]; then
 echo "--"
 echo ${i};
 apt-cache depends ${i}|grep ${1}
 echo "--"
 fi
done

 
     


To get and install whatdependsonfrominstalled.sh
# wget kod.ipduh.com/lib/whatdependsonfrominstalled.sh
# chmod 755 whatdependsonfrominstalled.sh
# mv whatdependsonfrominstalled.sh /usr/bin


Usage example
$ whatdependsonfrominstalled.sh rpcbind
--
nfs-common
  Depends: rpcbind
--


URI: http://alog.ipduh.com/2013/08/which-installed-debian-packages-depend.html