android 通过包名过滤logcat
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这个变量改下
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。