1. 程式人生 > 其它 >labelme標註後如何生成資料集

labelme標註後如何生成資料集

執行shell

sh xx.sh  執行指令碼
chmod+x ./xx.sh  執行許可權並執行指令碼
shell指令碼說白了就是一堆linux命令寫在一個檔案裡面,然後統一執行

變數

name="besttest"
age=18
class=("1班" "2班" "3班" )  輸出全部 echo ${class[*]}
${name}
$name
echo ${class[2]}  陣列取值

取長度

name="beijing"
echo ${#name}
echo ${#class[*]}
echo ${class[*]}  

輸入、輸出

echo "xxx"
read name
單引號和雙引號的區別 單引號是原樣字串,不會轉義

運算

sum=`expr 1 + 1`
sum2=`expr ${age} + 1`

條件判斷 --數值型運算子

-eq    等於
-ne   不等於
-lt   小於
-gt   大於
-lte   小於等於
-gte  大於等於

字串運算子

=
!=

if格式

echo "請輸入年齡:"
read age
if [ $age -gt 18 ]
then
echo "成年人"
elif [ $age -lt 18 ]
then
echo "未成年人"
else
echo "剛滿18 歲"
fi


and和or

age=8
if [ $age -gt 10 -a ` expr $age % 2 ` -eq 0 ]
#if [ $age -gt 10 -o ` expr $age % 2 ` -eq 0 ] then echo "是大於10的偶數" fi
字串判斷 name
="beijing" if [ $name != "beijing" ] then echo "北京" fi

迴圈-- 迴圈陣列

class=("1班" "2班" "3班" )
for item in ${class[*]}
do
echo $item
done


for迴圈

for num in 1 2 3 4 5 6
do
echo $num
done

while迴圈

count=0
while [ $count -lt 10 ]
do
echo $count
count
=`expr $count + 1` done

函式

基本格式
my_print (){
echo "nihao"
}


有入參的
oushu(){
number=$1
if [ 0 -eq `expr $number % 2` ]
then
echo "偶數"
else
echo "奇數"
fi
}

oushu 5
oushu 4


直接用來判斷的
abc="123"
delete(){
st=`expr 1 \* 1024`
file=$1
size=`du -k $file | awk '{print $1}'`
if [ $size -gt $st ]
then
abc="檔案大於100m"
return 0
else
return 1
fi
}

if delete "test2.sh"
then
rm -rf "test.sh"
fi


獲取返回結果的
delete "test2.sh"
result=$?
echo $result

重定向

content=`< test2.sh`
echo $content
keyword="nihao ya "
#echo $keyword > aaa.txt
echo $keyword >> aaa.txt

練習

啟動mysql的指令碼
arg
=$1 pid=`ps -ef|grep /opt/lampp/sbin/mysqld |grep -v grep|awk '{print $2}'` command="/opt/lampp/lampp startmysql" stop_command="/opt/lampp/lampp stopmysql" start(){ if [ $pid ] then echo "mysql 已經啟動了" else $command echo "mysql已啟動" fi }
stop(){
if [ $pid ] then $stop_command echo "mysql 已經停止" else echo "mysql未啟動" fi }

restart(){ stop start }
if [ "$arg" = "stop" -o "$arg" = "start" -o "$arg" = "restart" ] then $arg else echo "請輸入 start|stop|restart" fi

備份資料庫的指令碼
day=`date +%Y%m%d`
file_name="/tmp/${day}_all_data.sql"
mysqldump -uroot -p123456 -A > $file_name
echo "mysql 備份完成!"