rpm -qpl dhad-9.0.27891-2.x86_64.rpm
permite exibir todos os caminhos de arquivos e diretórios deste pacote.
Exemplo de saída:
/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
Eu querofiltrar apenas caminhos de arquivo:
eu tento :
rpm -qpl dhad-9.0.27891-2.x86_64.rpm | find -type f
Também :
rpm -qpl dhad-9.0.27891-2.x86_64.rpm|grep -f
Também :
rpm -qpl dhad-9.0.27891-2.x86_64.rpm |ls -f
Tudo não funcionou.
Responder1
Bem, isso foi horrível. Desde que a saída seja classificada assim, podemos analisá-la de trás para frente:
- Pegue a última linha
- Corte qualquer coisa depois da última
/
e guarde-a, e passe para a próxima linha - Se a linhanãoigual ao último nome do diretório, imprima
- Aumente a saída e volte para a etapa 2.
Para manter a ordem, também precisamos reverter novamente a saída. Felizmente, há um pequeno comando chamado tac
(o inverso de cat
) para tornar isso simples. Nós apenas o chamamos antes e depois do nosso script Bash:
... | tac | while read p; do [ "$l" != "$p" ] && echo "$p"; l="$(dirname "$p")"; done | tac
Observe que isso só funcionará se pudermos confiar na ordem dos arquivos. Acho que provavelmente podemos; Eu só vi arquivos de pacotes classificados assim, então presumo que seja padrão.
Ao tentar responder a isso, comecei a usar um método diferente com awk
. Parece que dou a maioria das minhas respostas em awk
-form atualmente, então aqui está o acima, conforme visto pelo awk:
... | tac | awk 'l!=$0{print}{sub(/\/[^\/]*$/,"",$1);l=$0}' | tac
É um pouco mais curto, mas duvido que seja mais rápido.
Responder2
Parece que README e LICENSE são arquivos. Então você poderia tentar,
rpm -qpl dhad-9.0.27891-2.x86_64.rpm | grep -P '.*\..*|README|LICENSE'
Responder3
Você precisariatestecada caminho de arquivo eu acho, por exemplo, algo como
some command \
| xargs -I{} sh -c 'test -f "$0" && printf "%s\n" "$0"' {}
ou
while read -r f; do
[[ -f "$f" ]] && printf "%s\n" "$f"
done < <(some command)