【问题标题】:How do I find the number of files in a directory?如何查找目录中的文件数?
【发布时间】:2018-10-01 17:06:29
【问题描述】:

我试图简单地计算 Android 设备上目录中的文件数。我正在通过 Windows10 命令提示符使用 adb shell。 find、wc、tree 和 tail 等实用程序似乎不起作用,例如:

`tree . | tail -1`

给予

`tmp-mksh: tree: not found`
`tmp-mksh: tail: not found`

我可以写一些 java 来做,但那太傻了 :) 有什么想法吗?

【问题讨论】:

  • 您可以安装busybox 并尝试这些命令。

标签: android file directory numbers adb


【解决方案1】:

尝试以下方法:

$ adb shell
generic_x86:/ $ cd yourDirectory
generic_x86:/yourDirectory $ ls | wc -l

例如,在模拟器中:

$ adb shell
generic_x86:/ $ cd sdcard
generic_x86:/sdcard $ ls | wc -l
10

编辑:

对于您可以尝试的设备:

$ adb shell
generic_x86:/ $ cd yourDirectory
generic_x86:/yourDirectory $ ls -l | grep . -c

【讨论】:

  • find、wc、tree 和 tail 等实用程序似乎不起作用
  • 它在模拟器中工作。我正在编辑以使其在设备中工作。
  • @user96279 有用吗?如果是,请采纳,如果不是,请评论!
猜你喜欢
  • 2011-04-11
  • 2012-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-01
  • 2013-01-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多