0

I am tinkering with Android developing. Using Ubuntu 16.04.3 LTS, Android Studio 3.0, Android Debug Bridge version 1.0.32.

I meant to get a dump of file sizes with

$ adb shell
shell@j7elte:/ $ uname -a                                                      
Linux localhost 3.10.61-10026643 #1 SMP PREEMPT Tue Feb 14 06:53:29 KST 2017 armv8l
shell@j7elte:/ $ du -n -d 1 | grep -i Permission                               

using grep -i to filter out lines with Permission denied. But neither -i or --invert-match work.

My two questions are:

For this specific case, what would the appropriate option be? (equivalent to --invert-match)

In general, how can I get the list of options with a description, for shell commands? I am used to grep --help, e.g., but it does not work. There is no man or info either.

3 Answers3

0

The set of shell commands used by Android seems to be toolbox. Information on it seems to be not centralized (which seems obscure to me), but one could search and find pieces of information around, e.g.

http://www.all-things-android.com/content/android-toolbox-command-reference

For the particular case of grep, this seems to be the applicable man page.

For "intensive" use of the command line, BusyBox is generally recommended as a replacement for toolbox.

Credits / Related:

https://android.stackexchange.com/questions/2149/where-can-i-find-documentation-for-shell-commands

How can I get information from the shell about commands available in Android shell?

How to execute the "help" Linux command on Android?

https://android.stackexchange.com/a/2153/81584

https://github.com/jackpal/Android-Terminal-Emulator/wiki/Android-Shell-Command-Reference

0

I guess this may vary between Android versions. On the device I have at hand right now (Samsung Galaxy S5) grep lists -v option (invert search) as valid but this does not work apparently:

shell@klte:/ $ grep
usage: grep [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A num] [-B num] [-C[num]]
    [-e pattern] [-f file] [--binary-files=value] [--color=when]
    [--context[=num]] [--directories=action] [--label] [--line-buffered]
    [pattern] [file ...]

shell@klte:/ $ df | grep -v 'Permission'                                     
/mnt/secure/asec: Permission denied
[snipped]

Some claim Android grep implementation is from NetBSD but it's buggy beyond anything but most basic filters.

zgoda
  • 12,775
  • 4
  • 37
  • 46
-1

yes. i do not think that the android shell is a terminal so it dosent have options like grep, nano, man, or info. Those can be found in a terminal. A fix for your situation might be UxTerm, try and download it from the android store

JosephWorks
  • 682
  • 4
  • 21
  • The shell in Android is similar to many others. It has builtin and external commands. In particular, it typically has `grep` available. But I do not know the details on the options for it. – sancho.s ReinstateMonicaCellio Jan 03 '18 at 01:33