0

Using less to view the output of some adb commands often does not work as expected.

For example hitting the spacebar to advance to the next screen often does nothing, but hitting the spacebar a second time will advance. (But this is inconsistent.)

Another quirk is that searching for a regular expression will return "Pattern not found" even though the pattern does actually exist.

To reproduce:

adb shell dumpsys jobscheduler | less

Actual behavior:

  • Hitting spacebar does not always advance to the next screen

Expected behavior:

  • Hitting spacebar reliably advances to the next screen

1 Answer 1

1

The problem is that adb shell reads from stdin (this does not appear to be documented), and this conflicts with less's efforts to also read from stdin.

A few ways to fix this:

# Provide the -n ("don't read from shell") switch
adb shell -n dumpsys jobscheduler | less

# Read from /dev/null
adb shell dumpsys jobscheduler </dev/null | less

# Replace "shell" with the (undocumented) exec-out command, which does not redirect stdin
adb exec-out dumpsys jobscheduler | less

# Run adb via process substitution
less <(adb shell dumpsys jobscheduler)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .