Skip to content

Instantly share code, notes, and snippets.

@sente
Created March 4, 2010 00:57
Show Gist options
  • Save sente/321274 to your computer and use it in GitHub Desktop.
Save sente/321274 to your computer and use it in GitHub Desktop.
#!/bin/sh
# stuart powers
# list the files installed from a specific package or all
# packages which match /pattern/ # one line of output per file:
# [exe|dir|pipe|etc] $PACKAGE $FILE
#to see all the executable files from libwww-perl:
#stu@sente ~ $ pkginfo.sh libwww-perl | grep ^x | cut -f3
# /usr/bin/lwp-download
# /usr/bin/lwp-mirror
# /usr/bin/lwp-rget
# /usr/bin/lwp-request
# /usr/bin/GET
# /usr/bin/POST
# /usr/bin/HEAD
#list installed apache packages:
#stu@sente ~ $ pkginfo.sh apache | cut -f2 | uniq
# apache2
# apache2-utils
# apache2.2-common
# libapache2-reload-perl
#show which packages have the most executables:
#stu@sente ~ $ pkginfo.sh | grep ^x | cut -f2 | uniq -c | sort -nr |head -5
# 131 git-core
# 96 coreutils
# 87 mailman
# 82 hal
# 70 texlive-base-bin
parm=$1
test -z $1 && parm=.
dpkg --list |
grep '^ii' |
grep -E "$parm" |
awk '{print $2}' |
while read package; do
dpkg -L $package |
while read file; do
#skips directories -- we only want files
# test -f "$file" || continue;
#if the file is executable, 'x', else 'f'
dest=
flag=
if [ -d "$file" ]; then
flag="dir"
elif [ -x "$file" ]; then
flag="exe"
fi
if [ -L "$file" ];
then flag="lnk"
fi;
if [ -L "$file" ];
then flag="lnk"
dest=$(readlink -e "$file")
fi;
if [ -L "$file" ];
then flag="pipe"
fi;
echo -e "$flag\t$package\t$file\t$dest";
done;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment