输出android目录结构的一个shell 脚本

来源:互联网 发布:现在拉货最火的软件 编辑:程序博客网 时间:2024/06/05 17:43

研究android时,我总想知道它的目录结构,于是写出了下面这个小脚本。adb有个特性,让使用unix/linux的人很反感,它行尾用\r\n,在调试程序时\r时常捣乱。在这个脚本中做了处理。

#!/bin/bash


# usage: list_android [-v]


# func: list_file

# arg1: directory

# arg2: indent

list_file() {

adb shell "ls -F $1 2>/dev/null" | \

while read i; do

fn=$(echo $i | cut -f2 -d ' ' | tr -d '\r')

if test "$verbose" = "true"; then

echo "$2"$(adb shell ls -ld ${1}/$fn)

else

echo "$2"$fn

fi


if test"$1" ="/" -a \("$fn" ="proc" -o"$fn" ="sys" \)

then

:

elif test"${i:0:1}" ='d'; then

list_file ${1}/$fn"$2 "

fi

done

}


if test"$1" ='-v'; then

verbose=true

fi


list_file '/' ""