-
Notifications
You must be signed in to change notification settings - Fork 0
/
find_soft.sh
executable file
·38 lines (29 loc) · 964 Bytes
/
find_soft.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
function FindSoftFromSpecDir()
{
SrcDir=$1
WildCard=$2
DstDir=$3
if [ ! -d $DstDir ];then
mkdir $DstDir -p
fi
if [ -z "$SrcDir" ] || [ -z "$WildCard" ] || [ -z "$DstDir" ]; then
echo "[$FUNCNAME:$LINENO]"
echo " SrcDir:$SrcDir,WildCard:$WildCard,DstDir:$DstDir."
return -1;
fi
SpecSoftName=`find "$SrcDir" -iname "$WildCard" | awk -F'/' '{ print $NF }' | sort -rn | awk '{ print $NR }' `
if [ 0 != $? ];then
echo "[$FUNCNAME:$LINENO]"
echo " SrcDir:$SrcDir,WildCard:$WildCard,DstDir:$DstDir."
return -1;
fi
SpecSrcFile=`find $SrcDir -iname $SpecSoftName `
cp -a $SpecSrcFile $DstDir/
if [ 0 != $? ] || [ -z $SpecSoftName ] || [ -z $SpecSrcFile ]; then
echo "[$FUNCNAME:$LINENO]"
echo " SpecSoftName:$SpecSoftName,SpecSrcFile:$SpecSrcFile,DstDir:$DstDir."
return -1;
fi
return 0;
}