我想从文本文件(yum存储库文件)中提取特定的文件路径。文件内容如下所示
[rhel-8-for-x86_64-baseos-rpms]
name = Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)
baseurl = https://myhost.com
enabled = 1
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
sslverify = 1
sslclientkey = /etc/pki/entitlement/60472949067-key.pem
sslclientcert = /etc/pki/entitlement/604712349067.pem
metadata_expire = 1
enabled_metadata = 1
[rhel-8-for-x86_64-appstream-rpms]
name = Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)
baseurl = https://myhost.com
enabled = 1
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
sslverify = 1
sslclientkey = /etc/pki/entitlement/6047297349067-key.pem
sslclientcert = /etc/pki/entitlement/6047297349067.pem
metadata_expire = 1
enabled_metadata = 1
我的要求是通过命令行或脚本提取rhel-8-for-x86_64-appstream-rpm和rhel-8-for-x86_64-baseos-rpm的sslclinetkey路径
任何帮助都将不胜感激
- 更新 *
我尝试过这种方法,但我得到多个条目
cat /etc/yum.repos.d/redhat.repo | grep sslclientkey | awk '{print $3}'
/etc/pki/entitlement/2627848977587647846-key.pem
/etc/pki/entitlement/7675461792121821585-key.pem
/etc/pki/entitlement/3236342435348109549-key.pem
/etc/pki/entitlement/60472974412349067-key.pem
/etc/pki/entitlement/3236342435348109549-key.pem
/etc/pki/entitlement/60472974412349067-key.pem
但我只需要rhel-8用于x86_64-appstream-rpm和rhel-8用于x86_64-baseos-rpm
2条答案
按热度按时间zhte4eai1#
m4pnthwp2#
它只是ini文件.所以crudini将做这项工作:
或对于所有部分: