Search code examples
shellreturnadb

why "adb shell ls /sdcard" return diffrent results


$ adb shell ls /sdcard/*|wc -l
42

$ adb shell ls /sdcard/|wc -l
25

I payed 2 commands through adb above, but gives 2 different results.

Some folder, for example "LOST.DIR" will appear in /sdcard/ but not in /sdcard/*

Why?


Solution

  • The first one is showing you everything in the sdcard directory, PLUS everything in one level of directories below that. That's also why LOST.DIR disappears; because there's nothing in it.

    Consider that ls /sd* would show you the content of the sdcard directory; that might help understand what's happening here. Wildcard expansion happens before running the external program ls.