adb shell 选择指定设备 的脚本

问题:
电脑连接两台以上的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.运行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值