|
发表于 2004-7-28 16:33:15
|
显示全部楼层
http://www.linuxsir.org/bbs/showthread.php?s=&threadid=90652
糊涂了我
用上面连接里的脚本就可以查询文件在那个包里。
[code:1]
#!/bin/bash
# whichpkg - list the slackware package(s) which installed
# the given file or directory;
# syntax: whichpkg name [...]
#
# starts with strict tests: full match on file or directory;
# if nothing found, try full match on .new or in;
# if nothing found, try substring match;
# multiple arguments are handled recursively.
#
# copyright 2004 by William Hunt, all rights reserved.
# distributed under terms of the Gnu Public License, version 2 or later.
# master distribution at ftp://prv8.net/slackstuff/
DATA=/var/log/packages/*
[ "$1" = . ] || [ "$1" = .. ] && shift # skip if given
[ "${1:0:2}" = ./ ] && F=${1:2} || F=$1 # trim relative root if given
[ "${1:0:1}" = / ] && F=${1:1} # trim absolute root if given
[ -z $F ] && exit # argument required
x=$( grep ^$F$ ${DATA} )
[ -z "$x" ] && x=$( grep ^$F/$ ${DATA} )
[ -z "$x" ] && x=$( grep ^$F.new$ ${DATA} )
[ -z "$x" ] && x=$( grep ^$F.in$ ${DATA} )
[ -z "$x" ] && x=$( grep /$F/$ ${DATA} | grep -v ":.*:" )
[ -z "$x" ] && x=$( grep /$F.new$ ${DATA} | grep -v ":.*:" )
[ -z "$x" ] && x=$( grep /$F.in$ ${DATA} | grep -v ":.*:" )
[ -z "$x" ] && x=$( grep /$F$ ${DATA} | grep -v ":.*:" )
for a in $x ; do b=${a%:*} ; echo ${b##*/} ; done | uniq
shift ; $0 $* # recursion.
# tha-tha-tha-that's all, folks!
[/code:1] |
|