【问题标题】:Android shell command options explainedAndroid shell 命令选项解释
【发布时间】:2018-01-02 23:15:47
【问题描述】:

我正在修补 Android 开发。使用 Ubuntu 16.04.3 LTS, 安卓工作室 3.0, Android 调试桥版本 1.0.32。

我的意思是获取文件大小的转储

$ 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                               

使用grep -i 过滤掉带有Permission denied 的行。但是-i--invert-match 都不起作用。

我的两个问题是:

对于这种特定情况,合适的选项是什么? (相当于--invert-match

一般来说,我怎样才能获得带有描述的选项列表,用于 shell 命令?我习惯了grep --help,例如,但它不起作用。也没有maninfo

【问题讨论】:

    标签: android shell command-line grep


    【解决方案1】:

    Android 使用的 shell 命令集似乎是toolbox。 关于它的信息似乎不是集中的(这对我来说似乎晦涩),但可以搜索并找到周围的信息,例如

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

    对于grep 的特殊情况,this 似乎是适用的手册页。

    对于命令行的“密集”使用,通常建议使用BusyBox 替代toolbox

    学分/相关:

    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

    【讨论】:

      【解决方案2】:

      我猜这可能因 Android 版本而异。在我现在手头的设备(三星 Galaxy S5)上,grep 将-v 选项(反向搜索)列为有效,但这显然不起作用:

      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]
      

      有些人声称 Android grep implementation is from NetBSD,但除了最基本的过滤器之外,它还有其他问题。

      【讨论】:

        【解决方案3】:

        是的。我不认为 android shell 是一个终端,所以它有 grep、nano、man 或 info 等选项。这些可以在终端中找到。 UxTerm 可以解决您的情况,尝试从 android 商店下载它

        【讨论】:

        • Android 中的外壳与许多其他外壳相似。它具有内置和外部命令。特别是,它通常有grep 可用。但我不知道它的选项的详细信息。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-21
        • 2019-10-11
        • 1970-01-01
        • 2020-12-10
        • 2013-08-26
        • 1970-01-01
        相关资源
        最近更新 更多