加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

adb shell 选择指定设备 的脚本

发布时间:2020-12-15 19:56:03 所属栏目:安全 来源:网络整理
导读:问题: 电脑连接两台以上的android 设备时 adb shell 会返回 more than one device 解决方法: Step1.获取设备列表 adb device 返回: List of devices attached 87381 d28093700000000 deviceyasudyasadasdasdasda device Step2.指定设备shell(比如选择12345

问题:

电脑连接两台以上的android 设备时

adb shell

会返回

more than one device

解决方法:

  • Step1.获取设备列表
adb device

返回:

List of devices attached
87381d28093700000000    device
yasudyasadasdasdasda    device
  • Step2.指定设备shell(比如选择123456)
adb -s 87381d28093700000000 shell

但是输入这么长的序列号,我还不如直接把其他的设备都拔掉…

或许可以写个脚本:

#!/bin/bash
PS3="please select a device :"
array=($(adb devices | grep ".device$"))
i=0
length=${#array[@]}
while [ "$i" -lt "$length" ];do
    if 
        ((i%2!=0)) 
    then
        unset array[i]  
    fi
    ((i++))
done
((length++))
array[$length]=exit
select var in "${array[@]}" ;do
    break
done
if 
    [[ "$var" != "exit" ]]
then
    echo "Please complete the order :"
    read -p "adb -s $var " cmd
    adb -s $var $cmd
fi

运行效果:

此脚本适用于Linux和Mac

使用方法:
1. 创建文件

vim adbdevice

2.拷贝代码

3.添加可执行权限

sudo chmod +x adbdevice

4.运行

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读