shell---rpm
[root@master src]# rpm -qpl epel-release-latest-6.noarch.rpm ##查询该rpm包安装了什么
warning: epel-release-latest-6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
/etc/rpm/macros.ghc-srpm
/etc/yum.repos.d/epel-testing.repo
/etc/yum.repos.d/epel.repo
/usr/share/doc/epel-release-6
/usr/share/doc/epel-release-6/GPL
[root@master src]# rpm -qpi epel-release-latest-6.noarch.rpm ##查询该包的一些信息
warning: epel-release-latest-6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Name : epel-release Relocations: (not relocatable)
Version : 6 Vendor: Fedora Project
Release : 8 Build Date: Mon 05 Nov 2012 11:54:41 AM CST
Install Date: (not installed) Build Host: buildvm-05.phx2.fedoraproject.org
Group : System Environment/Base Source RPM: epel-release-6-8.src.rpm
Size : 22169 License: GPLv2
Signature : RSA/8, Mon 05 Nov 2012 11:29:49 PM CST, Key ID 3b49df2a0608b895
Packager : Fedora Project
URL : http://dl.fedoraproject.org/pub/epel/
Summary : Extra Packages for Enterprise Linux repository configuration
Description :
This package contains the Extra Packages for Enterprise Linux (EPEL) repository
GPG key as well as configuration for yum and up2date.
[root@master src]# rpm -i --test jdk-7u79-linux-x64.rpm # 查询rpm包是否可以被安装.
package jdk-2000:1.7.0_79-fcs.x86_64 is already installed
installing package jdk-2000:1.7.0_79-fcs.x86_64 needs 195MB on the / filesystem
[root@master src]# echo $?
1
代码:
1 #!/bin/bash 2 # rpm-check.sh 3 4 # 这个脚本的目的是为了描述, 列表, 和确定是否可以安装一个rpm包. 5 # 在一个文件中保存输出. 6 # 7 # 这个脚本使用一个代码块来展示. 8 9 SUCCESS=0 10 E_NOARGS=65 11 12 if [ -z "$1" ] 13 then 14 echo "Usage: `basename $0` rpm-file" 15 exit $E_NOARGS 16 fi 17 18 { 19 echo 20 echo "Archive Description:" 21 rpm -qpi $1 # 查询说明. 22 echo 23 echo "Archive Listing:" 24 rpm -qpl $1 # 查询列表. 25 echo 26 rpm -i --test $1 # 查询rpm包是否可以被安装. 27 if [ "$?" -eq $SUCCESS ] 28 then 29 echo "$1 can be installed." 30 else 31 echo "$1 cannot be installed." 32 fi 33 echo 34 } > "$1.test" # 把代码块中的所有输出都重定向到文件中. 35 36 echo "Results of rpm test in file $1.test" 37 38 # 查看rpm的man页来查看rpm的选项. 39 40 exit 0
###########################shell 数组###################
[root@master ~]# Array[1]=slot_1
[root@master ~]# echo ${Array[1]}
slot_1
[root@master ~]# echo ${Array[*]}
slot_1
[root@master ~]# Array[2]=slot_2
[root@master ~]# echo ${Array[*]}
slot_1 slot_2
[root@master ~]# echo ${Array[2]}
slot_2