rpm -qpl dhad-9.0.27891-2.x86_64.rpm
允许显示此包的所有文件路径和目录路径。
输出示例:
/opt/dhad/tv_bin/wine/lib/wine/winmm.dll.so
/opt/dhad/tv_bin/wine/lib/wine/winspool.drv.so
/opt/dhad/tv_bin/wine/lib/wine/winsta.dll.so
/opt/dhad/tv_bin/wine/lib/wine/wintrust.dll.so
/opt/dhad/tv_bin/wine/lib/wine/ws2_32.dll.so
/opt/dhad/tv_bin/wine/lib/wine/wtsapi32.dll.so
/opt/dhad/tv_bin/wine/share
/opt/dhad/tv_bin/wine/share/wine
/opt/dhad/tv_bin/wine/share/wine/fonts
/opt/dhad/tv_bin/wine/share/wine/fonts/coue1255.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/coue1256.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/coue1257.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/coure.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/couree.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/coureg.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/courer.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/couret.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/cvgasys.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/hvgasys.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/jsmalle.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/jvgasys.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/marlett.ttf
/opt/dhad/tv_bin/wine/share/wine/fonts/smae1255.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smae1256.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smae1257.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smalle.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smallee.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smalleg.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smaller.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smallet.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssee1255.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssee1256.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssee1257.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssee874.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssef1255.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssef1256.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssef1257.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssef874.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sserife.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sserifee.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sserifeg.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sserifer.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sserifet.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sseriff.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sseriffe.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sseriffg.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sseriffr.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sserifft.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/svgasys.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/symbol.ttf
/opt/dhad/tv_bin/wine/share/wine/fonts/tahoma.ttf
/opt/dhad/tv_bin/wine/share/wine/fonts/tahomabd.ttf
/opt/dhad/tv_bin/wine/share/wine/fonts/vgas1255.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgas1256.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgas1257.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgas874.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgasys.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgasyse.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgasysg.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgasysr.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgasyst.fon
/opt/dhad/tv_bin/wine/share/wine/generic.ppd
/opt/dhad/tv_bin/wine/share/wine/l_intl.nls
/opt/dhad/tv_bin/wine/share/wine/wine.inf
/opt/dhad/tv_bin/xdg-utils
/opt/dhad/tv_bin/xdg-utils/LICENSE
/opt/dhad/tv_bin/xdg-utils/README
/opt/dhad/tv_bin/xdg-utils/xdg-desktop-icon
/opt/dhad/tv_bin/xdg-utils/xdg-desktop-menu
/opt/dhad/tv_bin/xdg-utils/xdg-email
/opt/dhad/tv_bin/xdg-utils/xdg-icon-resource
/opt/dhad/tv_bin/xdg-utils/xdg-mime
/opt/dhad/tv_bin/xdg-utils/xdg-open
/opt/dhad/tv_bin/xdg-utils/xdg-screensaver
/opt/dhad/tv_bin/xdg-utils/xdg-settings
/usr
/usr/bin
/usr/bin/viewer
/var
/var/log
/var/log/viewer
我想要仅过滤文件路径:
我尝试:
rpm -qpl dhad-9.0.27891-2.x86_64.rpm | find -type f
还 :
rpm -qpl dhad-9.0.27891-2.x86_64.rpm|grep -f
还 :
rpm -qpl dhad-9.0.27891-2.x86_64.rpm |ls -f
一切都没起作用。
答案1
那太糟糕了。不过,如果输出是这样排序的,我们可以反向查看它:
- 采取最后一行
- 删除最后一个之后的所有内容
/
并存储起来,然后转到下一行 - 如果没有等于最后一个目录名,打印
- 上移输出并返回步骤2。
为了保持顺序,我们还需要重新反转输出。幸运的是,有一个名为tac
(的反转cat
)的小命令可以简化这一过程。我们只需在 Bash 脚本之前和之后调用它即可:
... | tac | while read p; do [ "$l" != "$p" ] && echo "$p"; l="$(dirname "$p")"; done | tac
请注意,只有当我们能够依赖文件顺序时,这才会起作用。我想我们可能可以;我只见过像这样排序的包文件,所以我认为这是标准的。
当尝试回答这个问题时,我开始使用不同的方法awk
。这些天我似乎以 -form 的形式给出了大部分答案,awk
因此上面是 awk 看到的内容:
... | tac | awk 'l!=$0{print}{sub(/\/[^\/]*$/,"",$1);l=$0}' | tac
它稍微短了一点,但我怀疑它会更快。
答案2
README 和 LICENSE 似乎都是文件。因此你可以尝试,
rpm -qpl dhad-9.0.27891-2.x86_64.rpm | grep -P '.*\..*|README|LICENSE'
答案3
你需要测试我认为每个文件路径例如
some command \
| xargs -I{} sh -c 'test -f "$0" && printf "%s\n" "$0"' {}
或者
while read -r f; do
[[ -f "$f" ]] && printf "%s\n" "$f"
done < <(some command)