[Article]Workaround for grep and Logcat, dmesg, and last_kmsg on Windows
In this article, I will explain some of the confusions that may occur whilst using grep in logcat, dmesg, kmsg and last_kmsg on different platforms,mainly between Unix(Linux based such as ubuntu, linux mint, fedora, BSD based such as netbsd, freebsd, and even Mac) and Windows(Windows XP, Windows Vista, Windows 7, Windows 8 and etc).
- Known about the existence of logcat, dmesg, kmsg, and last_kmsg and have tried logging it at least once
- Know some basic knowledge of batch/bash(cmd/terminal)
- Using Windows OS(The problem only lies on Windows, so if you're using Mac or Linux then you're fine)
Although this is a rather technical article, but I will make it as simple as possible for all of the users to understand
Sometimes, I will see some of the developers will issue similar to this:
Log Commands with Grep
So, the problem is?
adb logcat | grep 'htc'
adb shell dmesg | grep 'mp_decision'
adb shell cat /proc/last_kmsg | grep 'mp_decision'
The problem is that if you're using a Windows OS, Windows OS doesn't have grep installed, so your command would not run and you will see an error message like this:
Linux or Mac users will not have this problem as they have grep installed, so they are fine.
1. Install a Linux shell on Windows
2. Use a terminal app within the Android phone
3. Connect to the linux shell inside the Android Phone by using your computer
4. Use the built-in filters(for logcat ONLY)
You can simply click here and follow the simple steps to get a linux shell on your computer
You just need to download a terminal app from your phone and every command will work fine. You would need to omit the adb and adb shell keyword(refer below) in order for the command to work. A nice terminal app suggestion would be https://play.google.com/store/apps/d...roidterm&hl=en which you can simply download from Google Playstore
You can just type "adb shell" and press enter, then type your commands(omit all adb and adb shell keyword) and it will work just as like in workaround #2.
1. "adb shell" + enter
2. Choose the command that you wanted:
logcat | grep 'htc'
dmesg | grep 'mp_decision'
cat /proc/last_kmsg | grep 'mp_decision'
This workaround is a workaround which only exists for logcat, because logcat have a filtering system that is built into it(makes us wonder why it is not built into dmesg and last_kmsg as well eh?).
For example, the grep command for the logcat above can be replaced by:
However, the downside is that you need to know the exact name of the app which is logged at the logcat in order to search for it while you can do a random keyword search with grep which helps a lot if you do not know what to look for.
For more information about the filtration, you can refer to http://developer.android.com/tools/d...gging-log.html
Hopefully, after reading this article, you will know how to deal with grep when you're on Windows OS
Do drop me a question or two if you have something that you don't understand and stay tuned for more articles!
Want to make a logcat, dmesg, last_kmsg but don't know how?
AIOlog is your logging solution: http://forum.xda-developers.com/show...php?p=32994107
Looking for beta testers and translators, please contact me if you're interested