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


#!/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,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。