Ask Your Question
3

How can the logcat output of Android adb command line be filtered using multiple keywords from a json format?

asked 2022-11-20 11:00:00 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2022-02-27 08:00:00 +0000

nofretete gravatar image

There is no direct way to filter the logcat output using multiple keywords from a json format. However, you can use a combination of grep and regular expressions to achieve this.

Here’s an example:

  1. Connect your Android device to your computer and run the following command in your terminal:
adb logcat -v time > logcat.log

This will capture the logcat output and save it to a file called logcat.log.

  1. Convert your json file to a text file using a tool like jq:
cat myjson.json | jq -r . > keywords.txt

This will create a text file containing all the keywords from your json file, one per line.

  1. Use grep to filter the logcat output using the keywords from keywords.txt:
grep -f keywords.txt logcat.log > filtered.log

This will create a new file called filtered.log that contains only the logcat messages that match the keywords from your JSON file.

Note that this method will only match exact keyword matches. If you need to match partial keywords or use more complex regular expressions, you will need to modify the regex patterns in the grep command accordingly.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-11-20 11:00:00 +0000

Seen: 7 times

Last updated: Feb 27 '22