首页 > 系统服务 > 详细

4、拷贝命令以及命令所对应的库文件脚本--创建小型linux

时间:2014-04-16 13:20:52      阅读:746      评论:0      收藏:0      [点我收藏+]


#!/bin/bash
# function:cp command and lib funciton
N=/mnt/sysroot
LDD () {
which $1 &>/dev/null
RETVAL=$?
if [ $RETVAL -ne 0 ];then
echo "The $1 is not esxits."
return $RETVAL
fi
# bring out $1
DIR=`which $1 |grep -o "/.*"`
# bring out before
DIR1=`which $1 |grep -o "/.*" | sed  "s@\(.*\)$1@\1@g"`
[ -d $N$DIR1 ] || mkdir -p $N$DIR
[ $? -eq 0 ] && echo "Directory create sucessful." || return 10
[ -e $N$DIR ] ||  cp -fp $DIR $N$DIR
[ $? -eq 0 ] && echo "$DIR command copy sucessful." || return 11
# Bring out lib file
LDDDIR=`ldd $DIR |grep -o "/[^[:space:]]*"`
for I in $LDDDIR;do
# Bring out lib dir
 LDDDIR1=`echo $I |sed "s@\(.*\)/[^/]*@\1@g"`
 [ -d $N$LDDDIR1 ] || mkdir -p $N$LDDDIR1 &>/dev/null
 [ -e $N$I ] || cp -fp $I $N$LDDDIR1
done
}
while true;do
read -p "Do you want copy command:(Y/n) " ANSWER
if [ "$ANSWER" = "Y" -o "$ANSWER" = "y"  ];then
       read -p "which your copy command: " COM
               LDD $COM
else
 echo "You do not copy command."
 exit 1
 break
fi
done

本文出自 “fish” 博客,请务必保留此出处http://seeds.blog.51cto.com/1501815/1396134

4、拷贝命令以及命令所对应的库文件脚本--创建小型linux,布布扣,bubuko.com

4、拷贝命令以及命令所对应的库文件脚本--创建小型linux

原文:http://seeds.blog.51cto.com/1501815/1396134

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!