-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread logcat using shell script.txt
54 lines (45 loc) · 1.33 KB
/
read logcat using shell script.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# read logcat instantly
logcat -e terminal | while IFS= read -r line; do
# Check if the line contains "terminal"
if [[ "$line" == *"terminal"* ]]; then
echo "string matched"
pkill logcat
break
fi
done
# if you need to clear logcat
logcat -b all -c && logcat -e terminal | while IFS= read -r line; do
# Check if the line contains "terminal"
if [[ "$line" == *"terminal"* ]]; then
echo "string matched"
pkill logcat
break
fi
done
# use you need to use grep
logcat -e terminal | while IFS= read -r line; do
# Check if the line contains "terminal"
if echo "$line" | grep -q terminal; then
echo "string matched"
pkill logcat
break
fi
done
# read logcat output every 1 secound
logcat -e terminal | while IFS= read -t 1 line; do
# Check if the line contains "terminal"
if [[ "$line" == *"terminal"* ]]; then
echo "string matched"
pkill logcat
break
fi
done
# Check if the line contains "string" or if 30 minutes have passed
start_time=$(date +%s)
logcat -e terminal | while IFS= read -r line; do
if [[ "$line" == *"command"* || $(($(date +%s) - start_time)) -ge 1800 ]]; then
echo "string matched or 30 minutes passed"
pkill command
break
fi
done