init
This commit is contained in:
commit
56aaedb715
64
program/run.sh
Executable file
64
program/run.sh
Executable file
@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
# get real path of softlink
|
||||
get_real_path() {
|
||||
local f="$1"
|
||||
while [ -h "$f" ]; do
|
||||
ls=`ls -ld "$f"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
f="$link"
|
||||
else
|
||||
f=`dirname "$f"`/"$link"
|
||||
fi
|
||||
done
|
||||
echo "$f"
|
||||
}
|
||||
|
||||
# Script dir
|
||||
prg_path=$(get_real_path "$0")
|
||||
echo "Script path [$prg_path]"
|
||||
|
||||
# Service home
|
||||
pushd $(dirname "$prg_path") > /dev/null
|
||||
export APP_HOME=$(dirname $(pwd))
|
||||
# Enter service Home
|
||||
echo "App home [$APP_HOME]"
|
||||
cd "$APP_HOME"
|
||||
|
||||
resultDir='执行结果'
|
||||
mdir -p "$resultDir"
|
||||
|
||||
# Find image dirs
|
||||
imageDirs=()
|
||||
while IFS= read -r -d $'\0'; do
|
||||
imageDirs+=("${REPLY%/*}")
|
||||
done < <(find . -regextype sed -regex '.*\.\(jpe\?g\|png\|gif\)' -not -path "./$resultDir/*" -print0)
|
||||
|
||||
# Get car dirs
|
||||
carDirs=($(echo "${imageDirs[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
|
||||
|
||||
while IFS= read -r line; do
|
||||
|
||||
if [[ -z "$line" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
for carDir in "${carDirs[@]}"; do
|
||||
carName="${carDir##*/}"
|
||||
# echo "carName: $carName"
|
||||
|
||||
if grep -q "$line" <<< "$carName"; then
|
||||
echo "Car $carName found."
|
||||
categoryDir="${carDir%/*}"
|
||||
categoryName="${categoryDir#*/}"
|
||||
carResult="$APP_HOME/$resultDir/$categoryName"
|
||||
echo "Car result: $carResult"
|
||||
mkdir -p "$carResult"
|
||||
mv "$carDir" "$carResult/"
|
||||
fi
|
||||
done
|
||||
|
||||
done < $APP_HOME/data.txt
|
||||
|
||||
popd > /dev/null
|
Loading…
x
Reference in New Issue
Block a user