log adb top to file in windows cygwin

2019-08-28 02:47发布

Trying to log cpu usage (to file) of my app under windows.

First I tried this usning cmd

adb shell top | grep com.myapp > log.log

Which gives "grep is not recognized as an internal or external command, operable program or batch file.". I guess windows doesn't any grep command?

Then I tried the same command usning cygwin terminal. This resulted in an empty logfile. So I ran the same command but without redirecting the output

adb shell top | grep com.myapp

This returned the expected output. I've also tried redirecting stderr with "2>&1". Didn't work.

What am I doing wrong?

1条回答
叼着烟拽天下
2楼-- · 2019-08-28 03:36

I have got the same problem and --line-buffered solved it.

For example

adb shell top | grep --line-buffered com.myapp > log.log

查看更多
登录 后发表回答