1 #!/bin/bash 2 3 if [[ ! -n $1 ]]; then 4 cat <<EOF 5 Usage: `basename $0` <packagename> 6 EOF 7 exit 1 8 fi11 12 package_name=$1 13 ip=110.1.1.19:5555 14 pid_list=$(adb -s $ip shell ps| grep $package_name) 15 if [[ -n $pid_list ]]; then 16 # find pid, grep logcat with pid(s) 17 #convert to egrep format 18 pid_list=$(echo $pid_list|awk ‘{print $2}‘|sed -r "s#(.*)#\\\(\[\ \]*\1\\\)#g"|tr ‘\n‘ ‘|‘) 19 #strip the last ‘|‘ 20 pid_list=${pid_list::-1} 21 #adb logcat | grep --color -E "$pid_list" | grep -vE "MediaPlayer" 22 adb -s $ip logcat *:D | grep --color -E "$pid_list" 23 fi
使用方法:参数跟上包名,同时将脚本里面ip这个变量改下
时间: 2024-10-22 10:23:43