本文来源电子发烧友社区,作者:先生, 帖子地址:
https://bbs.elecfans.com/jishu_2301466_1_1.html
开发板体验视频,详见作者原文帖子
创建方法如下:
sudo -s
touch grade.sh
vim grade.sh
#/bin/bash
#Verson:0.1
#Auther:diql
#Pragram:This pragram is calcula
tion your grade
#import an argument
read -p "Please input your grade:" x
declare -i x
#jugemet $x value is none or not
echo "You don't input your grade...."
exit 5
fi
#jugement the gread level
if [[ "$x" -ge "90" && "$x" -le "100" ]];then
echo "Congratulation,Your grade is A."
elif [[ "$x" -ge "80" && "$x" -le "89" ]];then
echo "Good,Your grade is B."
elif [[ "$x" -ge "70" && "$x" -le "79" ]];then
echo "Ok.Your grade is C."
elif [[ "$x" -ge "60" && "$x" -le "69" ]];then
echo "Yeah,Your grade is D."
elif [[ "$x" -lt "60" ]];then
echo "Right,Your grade is F."
else
echo "Unknow argument...."
fi
键入:
esc
:wq
chmod 700 grade.sh
./grade.sh
./build.sh all
/etc/update.sh
-----------------------------------------------------------
附带pwm071.sh
----------------------------------------------
#! /bin/sh
if [ $# != 2 ]; then
echo "$0 <1/0>"
echo "User:$0 P3_7 1"
exit 0
fi
VAL=$1
N=${VAL##*_}
T=${VAL#*P}
M=${T%_*}
GPIOID=$((${M} * 8 + ${N} + 120))
echo "==== GPIOID ${GPIOID} ======"
if [ ! -d /sys/class/gpio/gpio$GPIOID ]; then
echo $GPIOID > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio${GPIOID}/direction
fi
echo "===$1===$2"
echo $2 > /sys/class/gpio/gpio${GPIOID}/value
for((i=1;i<=10;i+=1))
do
sleep 1
echo $i
echo 1 > /sys/class/gpio/gpio${GPIOID}/value
sleep 1
echo 0 > /sys/class/gpio/gpio${GPIOID}/value
done