我想检查我的android设备的目录中是否有某个文件。
我在 Windows 批处理中使用以下行
adb shell find /mnt/sdcard/koinoxrista -name Bill.txt
如果文件存在,我想做一些事情,如果文件不存在,我想做一些事情。
我怎样才能做到这一点?
我想检查我的android设备的目录中是否有某个文件。
我在 Windows 批处理中使用以下行
adb shell find /mnt/sdcard/koinoxrista -name Bill.txt
如果文件存在,我想做一些事情,如果文件不存在,我想做一些事情。
我怎样才能做到这一点?
adb shell 不支持查找命令。此命令还将显示隐藏文件adb shell ls -laR | grep filename
当您知道确切的文件名时,您不需要使用任何额外的命令find
来查找它。只需使用内置的 shell 工具检查它是否存在:
adb shell "[ -f /mnt/sdcard/koinoxrista/Bill.txt ] && echo 'found'"
恐怕Android模拟器不提供“查找”程序。
find
自 6.0 版 (Mashmallow) 起,该命令在 Android 中受支持。
这是因为从那时起它就包括了 Toybox。