查询so库文件脚本

作者: admin 分类: Linux,Shell脚本 发布时间: 2018-05-18 10:49 浏览:1,104 次    

环境:Centos 7.4

使用方法: show-so  xxx.so.x

[root@localhost ~]# vim /usr/bin/show-so
###################################################################
# File Name: show-so.sh
# Author: xunyin
# E-mail: lnhxzwb@126.com
# Created Time: Fri 18 May 2018 05:01:02 PM CST
#==================================================================
#!/bin/bash
display ()
{
echo "$canshu 安装包为:"
echo "$so"
}

canshu=$1
what=$(yum whatprovides "$1" |grep -i no|awk '{print $1}')
what1=$(yum provides "$1" |grep -i no|awk '{print $1}')
so=$(yum whatprovides "$1" |grep -i libr|cut -d: -f1|sed -n 1p)
so1=$(yum provides "$1" |grep -i libr|cut -d: -f1|sed -n 1p)


yum whatprovides "$1" &>/dev/null
if [ "$what" = "No" ];then
yum -y install yum-utils &>/dev/null
yum whatprovides "$1" &>/dev/null
if [ "$what" = "No" ];then
yum provides "$1" &>/dev/null
if [ "$what1" = "No" ];then
echo "$canshu 查询失败,请减少关键字或手动查询"
else
echo "$canshu 安装包为:"
echo " $so1"
fi
else
display
fi
else
display
fi
[root@localhost ~]# chmod 755 /usr/bin/show-so

例:

[root@localhost ~]# show-so ld-linux.so.2
ld-linux.so.2 安装包为:
glibc-2.17-222.el7.i686

 

 


温馨提示:如无特殊说明,本站文章均为作者原创,转载时请注明出处及相应链接!

发表评论