简体   繁体   中英

Similar command to linux tree command in adb shell

I want to list all files and folders of music directory of android mobile. Where I am using

 ls -l -R /sdcard/music

It gives all files and folders but not in a proper way.

Any one tell me adb shell command that displays files and folders hierarchy of a directory like "tree" linux command.

I don't know if you still looking for this, but I believe this command can help you (works on adb as well):

find . -print | sort | sed 's;[^/]*/;|---;g;s;---|; |;g'

It prints a directory tree (both folders and files) in a more readable way than

 ls -l -R

If you want just a folder tree, you can use this one:

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'

You need to install busybox for android, it will add many well known linux tools to your phone. You need a rooted phone for installing busybox.

Check it out here: https://play.google.com/store/apps/details?id=stericson.busybox&hl=fr

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM