中括号判断用"="
if [[ ${pkg} = p ]]; then
获取文件名后缀
suffix=${pkg##*.}
grep使用正则表达式"-E"
adb devices|grep -E "device$|unauthorized|offline"|grep -E -n "device$|unauthorized|offline"
if比较使用正则表达式
if [[ ${device} =~ ${pattern1} ]]; then
读取输入时显示提示"-p"
read -p "ip:port" ip
使用``包围输出的内容传入变量
type=`echo $device|awk '{ print $3 }'`
整数运算
let retry_time+=1
获取字符串前3个
if [[ ${serial:0:3} != 172 ]]
打印日期时间
date +%F" "%T
for循环
for (( count = 0; count < $times; count++ )); do let x1=${RANDOM}%${xmax} let x2=${RANDOM}%${xmax} let y1=${RANDOM}%${ymax} let y2=${RANDOM}%${ymax} adb -s ${serial} shell input swipe ${x1} ${y1} ${x2} ${y2} 30 echo ${count}/${times} swipes @${serial} \(${x1},${y1}\)-\>\(${x2},${y2}\) done
while循环和case选择
while(true) do case $flag in 1 )set_package_input ; flag=$?;; 2 )set_package_name ; flag=$?;; 3 )skip_pkg_tmp ; flag=$?;; 4 )select_device ; flag=$?;; 5 )check_device ; flag=$?;; 6 )select_tool ; flag=$?;; 7 )jump_to_tool ; flag=$?;; 8 )a1 ; flag=$?;; 9 )install ; flag=$?;; 10 )replace_install ; flag=$?;; 11 )un_install ; flag=$?;; 12 )uninstall ; flag=$?;; 13 )clear_data ; flag=$?;; 14 )input_text ; flag=$?;; 15 )input_tap ; flag=$?;; 16 )input_swipe ; flag=$?;; 17 )force_stop ; flag=$?;; 18 )grant_permission ; flag=$?;; 19 )wake_up ; flag=$?;; esac done
标签:count,Shell,技巧,记录,RANDOM,flag,let,device,input From: https://www.cnblogs.com/fishegg/p/18677523